id: a1d03c9b40b344b2a10eb10a4ce4416e
parent_id: 
item_type: 1
item_id: 10aeef8b82294070bc3a72f82ee386c3
item_updated_time: 1764345482614
title_diff: "[{\"diffs\":[[1,\"Python + selenium + Chrome 模拟登陆QQ邮箱，批量下载附件，本地\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":45}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>Python + selenium + Chrome 模拟登陆QQ邮箱，批量下载附件，本地重命名</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"18303\\\"></a>\\\r\\\n<h1>Python + selenium + Chrome 模拟登陆QQ邮箱，批量下载附件，本地重命名</h1>\\\r\\\n\\\r\\\n<div><span>\\\n  <div style=\\\"--en-clipped-content:article\\\">\\\n<div><br/></div><div style=\\\"font-size: 16px; display:block; min-width: 100%; position: relative;\\\"> <div><div style=\\\"font-family:-apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;color:rgb(26, 26, 26);-webkit-tap-highlight-color:rgba(26, 26, 26, 0);background:rgb(255, 255, 255);\\\"><div><div><span><div style=\\\"background:rgb(255, 255, 255);min-width:1000px;overflow:hidden;\\\"><div style=\\\"box-sizing:border-box;overflow:hidden;\\\"><div style=\\\"overflow:hidden;width:690px;margin:0px auto;\\\"><h1 style=\\\"font:inherit;font-weight:600;font-size:24px;line-height:1.22;overflow-wrap:break-word;margin:24px 0px;\\\">Python + selenium + Chrome 模拟登陆QQ邮箱，批量下载附件，本地重命名</h1><div style=\\\"display:flex;-webkit-box-align:center;align-items:center;\\\"><div style=\\\"display:flex;-webkit-box-align:center;align-items:center;-webkit-box-flex:1;flex:1 1 0%;white-space:nowrap;overflow:hidden;\\\"><span><div style=\\\"position:relative;display:inline-block;\\\"><div><a href=\\\"https://www.zhihu.com/people/AmateurX\\\" style=\\\"color:inherit;text-decoration:none;\\\" target=\\\"_blank\\\"><img src=\\\":/bee109697f494979a40d0fa8c6c973a7\\\" type=\\\"image/jpeg\\\" data-filename=\\\"83422af5c4f37dc8b53bc329c6a8529d_l.jpg\\\" height=\\\"38\\\" style=\\\"background:rgb(255, 255, 255);border-radius:50%;vertical-align:top;\\\" width=\\\"38\\\"/></a></div></div></span><div style=\\\"-webkit-box-flex:1;flex:1 1 0%;margin-left:14px;overflow:hidden;\\\"><div style=\\\"display:flex;-webkit-box-align:center;align-items:center;font-size:15px;line-height:1.1;flex-shrink:0;\\\"><span style=\\\"font-weight:600;color:rgb(68, 68, 68);\\\"><div style=\\\"position:relative;display:inline-block;\\\"><div><a href=\\\"https://www.zhihu.com/people/AmateurX\\\" style=\\\"color:inherit;text-decoration:none;\\\" target=\\\"_blank\\\">鑫晴</a></div></div></span></div><div style=\\\"overflow:hidden;color:rgb(100, 100, 100);\\\"><div style=\\\"display:flex;-webkit-box-align:center;align-items:center;margin-top:2px;font-size:14px;\\\"><div style=\\\"word-break:break-word;line-height:1.6;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:rgb(100, 100, 100);\\\">不务正业</div></div></div></div></div></div><div><span style=\\\"display:block;margin-top:14px;font-size:14px;color:rgb(133, 144, 166);\\\"></span></div></div><div style=\\\"position:relative;width:690px;margin:0px auto;overflow:visible;\\\"><div style=\\\"word-break:break-word;line-height:1.6;margin-top:20px;\\\"><p style=\\\"margin:1.4em 0px;margin-top:0px;\\\">批量下载QQ邮箱附件，下载完后修改文件重命名 </p><p style=\\\"margin:1.4em 0px;\\\">---</p><p style=\\\"margin:1.4em 0px;\\\">因为工作原因，需要处理QQ邮箱上来自各地网友的投稿附件。数量比较多（上千份），如果手动一个一个下载非常麻烦。。。</p><p style=\\\"margin:1.4em 0px;\\\">而且有些发来的附件命名也不规范，下载下来之后还需要手动去重命名，否则放一起就分不清谁是谁了。而且也会出现大量重复的命名文件。 这种非常机械化的重复操作，我想写个脚本批量下载QQ邮箱附件。</p><p style=\\\"margin:1.4em 0px;\\\">于是临时研究了一下 Python + selenium + Chrome 来节省很多时间~<br/></p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><br/>如何安装</h2><p style=\\\"margin:1.4em 0px;\\\"><br/>- <b style=\\\"font-weight:600;\\\">Python 3</b><br/> <a href=\\\"https://link.zhihu.com/?target=https%3A//www.python.org/\\\" rel=\\\"nofollow noreferrer\\\" style=\\\"color:inherit;cursor:pointer;border-bottom:1px solid grey;text-decoration:none;\\\" target=\\\"_blank\\\"><span style=\\\"font:0px/0 a;color:transparent;text-shadow:none;background-color:transparent;\\\">https://www.</span><span>python.org/</span><span style=\\\"font:0px/0 a;color:transparent;text-shadow:none;background-color:transparent;\\\"></span></a><br/><br/>- <b style=\\\"font-weight:600;\\\">WebDriver for Chrome</b><br/> <a href=\\\"https://link.zhihu.com/?target=https%3A//sites.google.com/a/chromium.org/chromedriver/downloads\\\" rel=\\\"nofollow noreferrer\\\" style=\\\"color:inherit;cursor:pointer;border-bottom:1px solid grey;text-decoration:none;\\\" target=\\\"_blank\\\"><span style=\\\"font:0px/0 a;color:transparent;text-shadow:none;background-color:transparent;\\\">https://</span><span>sites.google.com/a/chro</span><span style=\\\"font:0px/0 a;color:transparent;text-shadow:none;background-color:transparent;\\\">mium.org/chromedriver/downloads</span><span><span style=\\\"\\\">...</span></span></a><br/><br/>- <b style=\\\"font-weight:600;\\\">selenium</b></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\">  pip install selenium</code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><br/>如何使用</h2><p style=\\\"margin:1.4em 0px;\\\">初次启用脚本需手动登陆，勾选<b style=\\\"font-weight:600;\\\">下次自动登陆</b> （记住密码） 以后再启用脚本时就可以实现自动登陆直接进入邮箱主页了。</p><p style=\\\"margin:1.4em 0px;\\\">不嫌麻烦的话，也可以先运行下面这段脚本来登陆。</p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\">from selenium import webdriver\\\n\\\noptions = webdriver.ChromeOptions()\\\noptions.add_argument(&quot;user-data-dir=selenium&quot;)\\\nchrome = webdriver.Chrome(options=options)\\\n\\\nurl = 'https://mail.qq.com/'\\\nchrome.get(url)\\\n\\\nprint('登陆成功！')</code></pre></div><p style=\\\"margin:1.4em 0px;\\\">&gt; 注：通过运行脚本启动的浏览器窗口，只能同时启动一个。若重复启动脚本将会打开空页面，需要关闭上一个窗口重新运行脚本。</p><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><h3 style=\\\"margin:0px;font:inherit;clear:left;margin-top:1.90909em;margin-bottom:1.27273em;font-size:1.1em;line-height:1.5;font-weight:600;\\\">2 调整每页显示邮件数量</h3><p style=\\\"margin:1.4em 0px;\\\">邮箱默认只显示25条邮件，需要在邮箱设置里，调整每页显示<b style=\\\"font-weight:600;\\\">100</b>封邮件。</p><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><h3 style=\\\"margin:0px;font:inherit;clear:left;margin-top:1.90909em;margin-bottom:1.27273em;font-size:1.1em;line-height:1.5;font-weight:600;\\\">3 邮箱文件夹</h3><p style=\\\"margin:1.4em 0px;\\\">把你想要下载的邮件<b style=\\\"font-weight:600;\\\">移动到</b>文件夹里，方便区分。</p><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><h3 style=\\\"margin:0px;font:inherit;clear:left;margin-top:1.90909em;margin-bottom:1.27273em;font-size:1.1em;line-height:1.5;font-weight:600;\\\">4 新窗口打开文件夹</h3><p style=\\\"margin:1.4em 0px;\\\">从邮箱左侧的面板‘我的文件夹’中找到你刚刚创建的文件夹，<b style=\\\"font-weight:600;\\\">右键-新窗口打开</b></p><p style=\\\"margin:1.4em 0px;\\\">从浏览器的地址栏找到链接的几个参数: <code style=\\\"margin:0px 2px;padding:3px 4px;border-radius:3px;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;font-size:0.9em;background-color:rgb(246, 246, 246);\\\">sid</code> <code style=\\\"margin:0px 2px;padding:3px 4px;border-radius:3px;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;font-size:0.9em;background-color:rgb(246, 246, 246);\\\">folderid</code> <code style=\\\"margin:0px 2px;padding:3px 4px;border-radius:3px;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;font-size:0.9em;background-color:rgb(246, 246, 246);\\\">page</code></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\">https://mail.qq.com/cgi-bin/frame_html?t=frame_html&amp;sid={ A }&amp;url=/cgi-bin/mail_list?folderid={ B }%26page={ C }</code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><h3 style=\\\"margin:0px;font:inherit;clear:left;margin-top:1.90909em;margin-bottom:1.27273em;font-size:1.1em;line-height:1.5;font-weight:600;\\\"><br/>5 修改脚本里面的自定义参数，然后启动脚本</h3><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># encoding:utf-8</span>\\\n<span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">os</span>\\\n<span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">urllib</span>\\\n<span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">_thread</span>\\\n<span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">time</span>\\\n<span style=\\\"font-weight:600;\\\">from</span> <span style=\\\"color:rgb(100, 100, 100);\\\">selenium</span> <span style=\\\"font-weight:600;\\\">import</span> <span>webdriver</span>\\\n<span style=\\\"font-weight:600;\\\">from</span> <span style=\\\"color:rgb(100, 100, 100);\\\">selenium.webdriver.common.keys</span> <span style=\\\"font-weight:600;\\\">import</span> <span>Keys</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 自定义参数</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 先登陆邮箱，找到你想处理的文件夹，右键新窗口打开，在浏览器地址栏可以看到以下地址:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># https://mail.qq.com/cgi-bin/frame_html?t=frame_html&amp;sid={ A }&amp;url=/cgi-bin/mail_list?folderid={ B }%26page={ C }</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 需要自定义的参数已在上方链接以 A B C 标记出，然后自己替换下面的参数</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># A - token['sid']         这串密钥会定时更新，每次使用时需要重新填写。</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># B - token['folderid']    文件夹ID</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># C - token['page']        邮件列表页数(初始页为0)。如果要下载第2页的邮件，就改为1。</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>token</span><span style=\\\"font-weight:600;\\\">=</span><span>{</span><span style=\\\"color:rgb(241, 64, 60);\\\">'sid'</span><span>:</span><span style=\\\"color:rgb(241, 64, 60);\\\">'123456'</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'folderid'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">156</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'page'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>}</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 附件下载到哪个文件夹。（如果文件夹不存在，会自动创建）</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 注：路径需要以双斜杠 \\\\\\\\ 作为分隔，不是单斜杠 \\\\</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>download_here</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"color:rgb(241, 64, 60);\\\">'D:</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\\\\</span><span style=\\\"color:rgb(241, 64, 60);\\\">emal'</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># Debug 模式 （0: 关闭 | 1: 开启）</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 开启DEBUG模式后，只输出列表数据，不下载任何附件。</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>DEBUG</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># pageInfo['now']     目前在第几页，默认为0，即第1页。</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># pageInfo['max']     文件夹共有几页</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># pageInfo['step']    希望下载至多少页</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>pageInfo</span><span style=\\\"font-weight:600;\\\">=</span><span>{</span><span style=\\\"color:rgb(241, 64, 60);\\\">'now'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'max'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'step'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'isfilp'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'autofilp'</span><span>:</span><span style=\\\"font-weight:600;\\\">True</span><span>}</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># title['index']    第index封邮件，默认为1，不可修改。</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># title['start']    从第start封邮件开始，默认为1</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># title['end']      到第end封邮件结束，默认为-1</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># title['step']     读取邮件次数超过step时结束，默认为-1</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>title</span><span style=\\\"font-weight:600;\\\">=</span><span>{</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'start'</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'end'</span><span>:</span><span style=\\\"font-weight:600;\\\">-</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'step'</span><span>:</span><span style=\\\"font-weight:600;\\\">-</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>}</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># TODO 还没花时间写完的功能</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># for name in title:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   for key in ignore_keys:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#     if key in name:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 关键词屏蔽（黑名单）</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ignore_keys 全局关键词，无论在哪里出现都跳过</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ignore_tile_keys 从邮件标题搜索</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ignore_user_keys 从发信人昵称搜索</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ignore_file_keys 从附件文件名搜索</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>ignore_keys</span> <span style=\\\"font-weight:600;\\\">=</span> <span>[]</span>\\\n<span>ignore_tile_keys</span><span style=\\\"font-weight:600;\\\">=</span><span>[]</span>\\\n<span>ignore_user_keys</span><span style=\\\"font-weight:600;\\\">=</span><span>[]</span>\\\n<span>ignore_file_keys</span><span style=\\\"font-weight:600;\\\">=</span><span>[]</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 用来测试的其他参数</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 用来计数测试用的，总感觉有时会漏掉一些文件。</span>\\\n<span>test</span><span style=\\\"font-weight:600;\\\">=</span><span>{</span><span style=\\\"color:rgb(241, 64, 60);\\\">'fileindex'</span><span>:</span> <span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'filecount'</span><span>:</span> <span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>,</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'downloadtimes'</span><span>:</span> <span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>}</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># readmail  邮件列表：包含邮件id(value)、时间戳(totime)、发件人邮箱(fa)、发件人昵称(fn)</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># filemail  附件列表：包含邮箱、邮件主题、发件人昵称、附件名</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># foolmail  没有附件：包含发件人昵称</span>\\\n<span>readmail</span><span>,</span><span>filemail</span><span>,</span><span>foolmail</span><span style=\\\"font-weight:600;\\\">=</span><span>[],[],[]</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 邮箱地址</span>\\\n<span>url_qqmail</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"color:rgb(241, 64, 60);\\\">'https://mail.qq.com/'</span>\\\n<span>url_folder</span><span style=\\\"font-weight:600;\\\">=</span><span>url_qqmail</span><span style=\\\"font-weight:600;\\\">+</span><span style=\\\"color:rgb(241, 64, 60);\\\">'cgi-bin/mail_list?sid=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&amp;folderid=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&amp;page=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>token</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'sid'</span><span>],</span><span>token</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'folderid'</span><span>],</span><span>token</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'page'</span><span>])</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 检查下载路径是否存在</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-weight:600;\\\">if</span> <span style=\\\"font-weight:600;\\\">not</span> <span>os</span><span style=\\\"font-weight:600;\\\">.</span><span>path</span><span style=\\\"font-weight:600;\\\">.</span><span>exists</span><span>(</span><span>download_here</span><span>):</span>\\\n    <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;文件夹不存在。正在自动创建文件夹....&quot;</span><span>)</span>\\\n    <span>os</span><span style=\\\"font-weight:600;\\\">.</span><span>mkdir</span><span>(</span><span>download_here</span><span>)</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 配置Web Driver</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">=</span><span>webdriver</span><span style=\\\"font-weight:600;\\\">.</span><span>ChromeOptions</span><span>()</span>\\\n<span>prefs</span><span style=\\\"font-weight:600;\\\">=</span><span>{</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;profile.managed_default_content_settings.images&quot;</span><span>:</span><span style=\\\"color:rgb(0, 132, 255);\\\">2</span><span>,</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;download.default_directory&quot;</span><span>:</span><span>download_here</span><span>}</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_argument</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;user-data-dir=selenium&quot;</span><span>)</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_experimental_option</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;prefs&quot;</span><span>,</span><span>prefs</span><span>)</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_argument</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;--window-size=720,800&quot;</span><span>)</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_argument</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'--ignore-certificate-errors'</span><span>)</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">=</span><span>webdriver</span><span style=\\\"font-weight:600;\\\">.</span><span>Chrome</span><span>(</span><span>options</span><span style=\\\"font-weight:600;\\\">=</span><span>options</span><span>)</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 启动Web Driver</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; &quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; Chrome启动&quot;</span><span>)</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>get</span><span>(</span><span>url_qqmail</span><span>)</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>implicitly_wait</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">3</span><span>)</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 获取页面信息</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n\\\n<span style=\\\"font-weight:600;\\\">while</span> <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'autofilp'</span><span>]:</span>\\\n  <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>get</span><span>(</span><span>url_folder</span><span>)</span>\\\n  <span>element</span> <span style=\\\"font-weight:600;\\\">=</span> <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_id</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;mainFrame&quot;</span><span>)</span>\\\n  <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>frame</span><span>(</span><span>element</span><span>)</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">if</span> <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'isfilp'</span><span>]</span><span style=\\\"font-weight:600;\\\">==</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>:</span>\\\n    <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'now'</span><span>]</span><span style=\\\"font-weight:600;\\\">=</span><span>token</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'page'</span><span>]</span><span style=\\\"font-weight:600;\\\">+</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n    <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'max'</span><span>]</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"color:rgb(0, 132, 255);\\\">eval</span><span>(</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_class_name</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;right&quot;</span><span>)[</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>]</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_tag_name</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'script'</span><span>)[</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span style=\\\"font-weight:600;\\\">+</span><span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'isfilp'</span><span>]]</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'innerHTML'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>strip</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'document.write('</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>strip</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">');'</span><span>))</span>\\\n    <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; ---- 进入文件夹: &quot;</span><span>,</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;qqmail_mailcontainer&quot;]/div[1]'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>text</span><span style=\\\"font-weight:600;\\\">.</span><span>strip</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'管理&quot;我的文件夹&quot;'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>strip</span><span>())</span>\\\n\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;当前是第</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">/</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">页&quot;</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'now'</span><span>],</span><span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'max'</span><span>]))</span>\\\n\\\n  <span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#翻页规则</span>\\\n  <span>can_filp_1</span> <span style=\\\"font-weight:600;\\\">=</span> <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'now'</span><span>]</span> <span style=\\\"font-weight:600;\\\">&lt;</span> <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'max'</span><span>]</span>\\\n  <span>can_filp_2</span> <span style=\\\"font-weight:600;\\\">=</span> <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'now'</span><span>]</span> <span style=\\\"font-weight:600;\\\">&lt;</span> <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'step'</span><span>]</span>\\\n\\\n  <span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 获取邮件列表</span>\\\n  <span>elements</span><span style=\\\"font-weight:600;\\\">=</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_css_selector</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'input[name=&quot;mailid&quot;]'</span><span>)</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">for</span> <span>e</span> <span style=\\\"font-weight:600;\\\">in</span> <span>elements</span><span>[</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>:]:</span>\\\n    <span style=\\\"font-weight:600;\\\">try</span><span>:</span>\\\n      <span style=\\\"font-weight:600;\\\">if</span> <span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>]</span> <span style=\\\"font-weight:600;\\\">&gt;=</span> <span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'start'</span><span>]:</span>\\\n        <span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># check = (false, true)[num == -1]</span>\\\n        <span>check_step</span> <span style=\\\"font-weight:600;\\\">=</span> <span>(</span><span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>]</span><span style=\\\"font-weight:600;\\\">-</span><span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'start'</span><span>]</span> <span style=\\\"font-weight:600;\\\">&lt;</span> <span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'step'</span><span>],</span><span style=\\\"font-weight:600;\\\">True</span><span>)[</span><span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'step'</span><span>]</span> <span style=\\\"font-weight:600;\\\">==</span> <span style=\\\"font-weight:600;\\\">-</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>]</span>\\\n\\\n        <span style=\\\"font-weight:600;\\\">if</span> <span>check_step</span><span>:</span>\\\n          <span>sender</span><span style=\\\"font-weight:600;\\\">=</span><span>{}</span>\\\n          <span>sender</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'timestamp'</span><span>:</span> <span>e</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'totime'</span><span>)})</span>\\\n          <span>sender</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'name'</span><span>:</span> <span>e</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'fn'</span><span>)})</span>\\\n          <span>sender</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'email'</span><span>:</span> <span>e</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'fa'</span><span>)})</span>\\\n          <span>sender</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'id'</span><span>:</span> <span>e</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'value'</span><span>)})</span>\\\n          <span>sender</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>:</span> <span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>]})</span>\\\n          <span>readmail</span><span style=\\\"font-weight:600;\\\">.</span><span>append</span><span>(</span><span>sender</span><span>)</span>\\\n          <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">' ├─</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\"> </span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>],</span><span>sender</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'name'</span><span>]))</span>\\\n          <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0.002</span><span>)</span>\\\n\\\n      <span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>]</span><span style=\\\"font-weight:600;\\\">+=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n    <span style=\\\"font-weight:600;\\\">except</span> <span style=\\\"font-weight:600;color:rgb(241, 64, 60);\\\">Exception</span> <span style=\\\"font-weight:600;\\\">as</span> <span>e</span><span>:</span>\\\n      <span style=\\\"font-weight:600;\\\">break</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">if</span> <span>can_filp_2</span><span>:</span>\\\n    <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'isfilp'</span><span>]</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n    <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'now'</span><span>]</span><span style=\\\"font-weight:600;\\\">+=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n    <span>url_folder</span><span style=\\\"font-weight:600;\\\">=</span><span>url_qqmail</span><span style=\\\"font-weight:600;\\\">+</span><span style=\\\"color:rgb(241, 64, 60);\\\">'cgi-bin/mail_list?sid=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&amp;folderid=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&amp;page=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>token</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'sid'</span><span>],</span><span>token</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'folderid'</span><span>],</span><span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'now'</span><span>]</span><span style=\\\"font-weight:600;\\\">-</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>)</span>\\\n  <span style=\\\"font-weight:600;\\\">else</span><span>:</span>\\\n    <span>pageInfo</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'autofilp'</span><span>]</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"font-weight:600;\\\">False</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 开始处理附件</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#......................................................</span>\\\n<span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>)</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#os.system('cls')</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\n</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; ---------------------------------------&quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">' 邮件主题(</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">)'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>title</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>]</span><span style=\\\"font-weight:600;\\\">-</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>))</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; ---------------------------------------&quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; &quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; 开始处理附件&quot;</span><span>)</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 获取每封邮件的附件列表</span>\\\n<span style=\\\"font-weight:600;\\\">for</span> <span>key</span> <span style=\\\"font-weight:600;\\\">in</span> <span>readmail</span><span>:</span>\\\n  <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0.012</span><span>)</span>\\\n  <span>url</span><span style=\\\"font-weight:600;\\\">=</span><span>url_qqmail</span><span style=\\\"font-weight:600;\\\">+</span><span style=\\\"color:rgb(241, 64, 60);\\\">'cgi-bin/frame_html?sid=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&amp;url=/cgi-bin/readmail?mailid=</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>token</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'sid'</span><span>],</span><span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'id'</span><span>])</span>\\\n  <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>get</span><span>(</span><span>url</span><span>)</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">try</span><span>:</span>\\\n    <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>default_content</span><span>()</span>\\\n    <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_id</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;mainFrame&quot;</span><span>)</span>\\\n  <span style=\\\"font-weight:600;\\\">except</span> <span style=\\\"font-weight:600;color:rgb(241, 64, 60);\\\">Exception</span> <span style=\\\"font-weight:600;\\\">as</span> <span>e</span><span>:</span>\\\n    <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;您请求的频率太快，请稍后再试&quot;</span><span>)</span>\\\n    <span>os</span><span style=\\\"font-weight:600;\\\">.</span><span>system</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'pause'</span><span>)</span>\\\n    <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>get</span><span>(</span><span>url</span><span>)</span>\\\n\\\n  <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>default_content</span><span>()</span>\\\n  <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>frame</span><span>(</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_id</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;mainFrame&quot;</span><span>))</span>\\\n  <span>elements</span><span style=\\\"font-weight:600;\\\">=</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_class_name</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;name_big&quot;</span><span>)</span>\\\n\\\n  <span>isFool</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"color:rgb(0, 132, 255);\\\">len</span><span>(</span><span>elements</span><span>)</span><span style=\\\"font-weight:600;\\\">&lt;=</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span>  <span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#没有附件</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">' ├─</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\"> </span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\"> </span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'index'</span><span>],</span><span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'name'</span><span>],(</span><span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'email'</span><span>],</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'(没有附件)'</span><span>)[</span><span>isFool</span><span>]))</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">if</span> <span>isFool</span><span>:</span>\\\n      <span>foolmail</span><span style=\\\"font-weight:600;\\\">.</span><span>append</span><span>(</span><span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'name'</span><span>])</span>\\\n      <span>mark_star</span><span style=\\\"font-weight:600;\\\">=</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_id</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;img_star&quot;</span><span>)</span>\\\n      <span style=\\\"font-weight:600;\\\">if</span> <span>mark_star</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;class&quot;</span><span>)</span> <span style=\\\"font-weight:600;\\\">==</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'qm_ico_flagoff'</span><span>:</span>\\\n          <span>mark_star</span><span style=\\\"font-weight:600;\\\">.</span><span>send_keys</span><span>(</span><span>Keys</span><span style=\\\"font-weight:600;\\\">.</span><span>SPACE</span><span>)</span>\\\n      <span style=\\\"font-weight:600;\\\">continue</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">for</span> <span>f</span> <span style=\\\"font-weight:600;\\\">in</span> <span>elements</span><span>:</span>\\\n      <span>attach</span><span style=\\\"font-weight:600;\\\">=</span><span>{}</span>\\\n      <span>attach</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'title'</span><span>:</span> <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_id</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;subject&quot;</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>text</span><span>})</span>\\\n      <span>attach</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'name'</span><span>:</span> <span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'name'</span><span>]})</span>\\\n      <span>attach</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'email'</span><span>:</span> <span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'email'</span><span>]})</span>\\\n      <span>attach</span><span style=\\\"font-weight:600;\\\">.</span><span>update</span><span>({</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filename'</span><span>:</span> <span>f</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_css_selector</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'span:nth-child(1)'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>text</span><span>})</span>\\\n      <span>filemail</span><span style=\\\"font-weight:600;\\\">.</span><span>append</span><span>(</span><span>attach</span><span>)</span>\\\n      <span>test</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filecount'</span><span>]</span><span style=\\\"font-weight:600;\\\">+=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n      <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; │  ├─</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>attach</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filename'</span><span>]))</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">if</span> <span>DEBUG</span> <span style=\\\"font-weight:600;\\\">!=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>:</span>\\\n      <span>os</span><span style=\\\"font-weight:600;\\\">.</span><span>chdir</span><span>(</span><span>download_here</span><span>)</span>\\\n      <span>cmd</span><span style=\\\"font-weight:600;\\\">=</span><span style=\\\"color:rgb(0, 132, 255);\\\">open</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;_ren.bat&quot;</span><span>,</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;a&quot;</span><span>)</span>\\\n      <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>seek</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>)</span>\\\n      <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>truncate</span><span>()</span>\\\n      <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;@echo off&quot;</span><span>)</span>\\\n      <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\n</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span>)</span>\\\n\\\n      <span style=\\\"font-weight:600;\\\">for</span> <span>key</span> <span style=\\\"font-weight:600;\\\">in</span> <span>filemail</span><span>:</span>\\\n        <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'ren &quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; &quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">-</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filename'</span><span>],</span> <span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'email'</span><span>],</span> <span>key</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filename'</span><span>]))</span>\\\n        <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\n</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span>)</span>\\\n\\\n      <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;del _ren.bat&quot;</span><span>)</span>\\\n      <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>close</span><span>()</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">if</span> <span>DEBUG</span> <span style=\\\"font-weight:600;\\\">!=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>:</span>\\\n    <span>elements</span><span style=\\\"font-weight:600;\\\">=</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_link_text</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'下载'</span><span>)</span>\\\n    <span style=\\\"font-weight:600;\\\">for</span> <span>e</span> <span style=\\\"font-weight:600;\\\">in</span> <span>elements</span><span>:</span>\\\n        <span>e</span><span style=\\\"font-weight:600;\\\">.</span><span>click</span><span>()</span>\\\n        <span>test</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'downloadtimes'</span><span>]</span><span style=\\\"font-weight:600;\\\">+=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n        <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0.18</span><span>)</span>\\\n\\\n    <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0.75</span><span>)</span>\\\n\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">' └─Emailecount:</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">    Foolcount:</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">    filecount:</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">    downloadtimes:</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">len</span><span>(</span><span>readmail</span><span>),</span> <span style=\\\"color:rgb(0, 132, 255);\\\">len</span><span>(</span><span>foolmail</span><span>),</span> <span>test</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filecount'</span><span>],</span><span>test</span><span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'downloadtimes'</span><span>]))</span>\\\n</code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\">特性\\\n1. 可以自定义附件的下载路径\\\n2. 可以自定义脚本从第几封邮件开始，处理多少封邮件后结束。\\\n3. 自动翻页（如果上面这里填写开始的位置大于页面显示的数量将自动翻页）\\\n4. 如果邮件中没有包含附件，会自动打星标。\\\n5. 脚本结束后会生成一个批处理程序，运行后会自动为附件重命名。命名规则是在文件名前面添加'发件人邮箱'\\\n\\\n\\\n可能出现的BUG\\\n1. 如果网络不稳定。附件的预览图如果没有加载出来，脚本可能会卡住。\\\n（已修复。解决方案：以不加载图片的模式启动浏览器）\\\n\\\n2. 如果窗口太小，可能获取不到页面元素，然后报错。\\\n（已修复。解决方案：在启动浏览器时调整窗口大小至合适的值，主要是高度）\\\n\\\n3. 本地重命名的批处理脚本，如果附件有重复的文件，后面的相同的文件不会被重命名。\\\n（没想好。临时解决方案：根据控制台输出的记录，搜索文件名，找到发件人昵称或者邮箱，手动重命名）\\\n\\\n4. 如果开车的速度过快，会被系统拦下车。提示：【您请求的频率太快，请稍后再试】\\\n（没写完。临时解决方案：根据控制台输出的记录，从暂停的地方重新下载）\\\n\\\n\\\n踩坑历史\\\n1. 附件收藏中的&quot;全部附件&quot;，并不是想象中真的把全部附件整合在一起，偶尔还是会漏掉一些。\\\n （已解决。换成进入邮件主题模拟手动下载附件）</code></pre></div><hr style=\\\"margin:4em auto;width:240px;max-width:100%;border-right:none;border-bottom:none;border-left:none;border-image:initial;border-top:1px solid rgb(211, 211, 211);\\\"/><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><blockquote style=\\\"margin:1.4em 0px;padding-left:1em;color:rgb(100, 100, 100);border-left:3px solid rgb(211, 211, 211);\\\">正文在这里已经结束了。以下内容为黑历史，懒得删。<br/>没啥重要的东西，可以无视</blockquote><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">2 进入附件收藏</b></h2><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">踩坑补充：（附件收藏的全部附件，居然不是“全部附件”，有些邮件的附件会漏掉！！！被TX坑了！！所以才更换为上方的方案）</b></h2><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 进入附件收藏</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;folder_attach&quot;]'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>click</span><span>()</span>\\\n\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>default_content</span><span>()</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>frame</span><span>(</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;mainFrame&quot;]'</span><span>))</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 查看全部附件</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;empty_tips&quot;]/p/a'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>click</span><span>()</span></code></pre></div><p style=\\\"margin:1.4em 0px;\\\"><br/><b style=\\\"font-weight:600;\\\">对了对了！这里还踩到了一个坑！！</b></p><blockquote style=\\\"margin:1.4em 0px;padding-left:1em;color:rgb(100, 100, 100);border-left:3px solid rgb(211, 211, 211);\\\">左边菜单栏中的“附件收藏”和中间的“全部附件”其实在两个不同的iframe里。<br/>需要切换通过 <code style=\\\"margin:0px 2px;padding:3px 4px;border-radius:3px;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;font-size:0.9em;background-color:rgb(246, 246, 246);\\\">switch_to_frame</code>  来切换框架，否则会出现 <code style=\\\"margin:0px 2px;padding:3px 4px;border-radius:3px;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;font-size:0.9em;background-color:rgb(246, 246, 246);\\\">NoSuchElementException</code> 的错误！</blockquote><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">进了全部附件，就可以看到所有的附件列表了.</p><p style=\\\"margin:1.4em 0px;\\\">接下来要抓取每个附件的资料</p><p style=\\\"margin:1.4em 0px;\\\">--------------------------------------------</p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">3 获取附件列表</b></h2><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 获取附件列表</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">list</span> <span style=\\\"font-weight:600;\\\">=</span> <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;list&quot;]/ul'</span><span>)</span>\\\n<span>items</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">list</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_tag_name</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;li&quot;</span><span>)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">--------------------------------------------</p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">4 整理附件信息</b></h2><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-weight:600;\\\">for</span> <span>item</span> <span style=\\\"font-weight:600;\\\">in</span> <span>items</span><span>:</span>\\\n  <span>rank</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'rank'</span><span>)</span>\\\n  <span>email</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_tag_name</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;span&quot;</span><span>)[</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>]</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'title'</span><span>)</span>\\\n  <span>sender</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'sender'</span><span>)</span>\\\n  <span>filename</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filename'</span><span>)</span>\\\n  <span>fileextenal</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'fileextenal'</span><span>)</span>\\\n  <span>filebyte</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filebyte'</span><span>)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">拿到了数据，接下来就是要把附件都下载下来。<br/>--------------------------------------------</p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">5 批量下载</b></h2><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 写在开头 options 下边</span>\\\n<span>download_here</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'E:</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\\\\</span><span style=\\\"color:rgb(241, 64, 60);\\\">Downloads</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\\\\</span><span style=\\\"color:rgb(241, 64, 60);\\\">email'</span>\\\n\\\n<span>prefs</span> <span style=\\\"font-weight:600;\\\">=</span> <span>{</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;download.default_directory&quot;</span> <span>:</span> <span>download_here</span><span>}</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_experimental_option</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;prefs&quot;</span><span>,</span><span>prefs</span><span>)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># for item in items:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ...</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ...</span>\\\n\\\n <span>downurl</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'downurl'</span><span>)</span>\\\n <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>execute_script</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;window.open('</span><span style=\\\"color:rgb(241, 64, 60);\\\">%s</span><span style=\\\"color:rgb(241, 64, 60);\\\">');&quot;</span><span style=\\\"font-weight:600;\\\">%</span><span>downurl</span><span>)</span>\\\n\\\n <span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 下载前等0.1秒，防止抽风</span>\\\n <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0.1</span><span>)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">这样只抓取到1页的内容，要下载其他页就得设置一下翻页了。</p><p style=\\\"margin:1.4em 0px;\\\">--------------------------------------------</p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">6 翻页下载</b></h2><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span>target_page</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">2</span>\\\n\\\n<span style=\\\"font-weight:600;\\\">while</span> <span>target_page</span> <span style=\\\"font-weight:600;\\\">&gt;</span> <span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>:</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">next</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">list</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;div_foot_right&quot;]/a[3]'</span><span>)</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;跳转页面&quot;</span><span>)</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">next</span><span style=\\\"font-weight:600;\\\">.</span><span>click</span><span>()</span>\\\n  <span>target_page</span><span style=\\\"font-weight:600;\\\">-=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n  <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>)</span>\\\n</code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><b style=\\\"font-weight:600;\\\">对了对了！这里还踩到了一个坑！！</b></p><blockquote style=\\\"margin:1.4em 0px;padding-left:1em;color:rgb(100, 100, 100);border-left:3px solid rgb(211, 211, 211);\\\">因为附件信息储存在前面的&lt;li&gt;。翻页之后，需要刷新一下&lt;li&gt;，才能拿到翻页后的。</blockquote><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">文件都下载下来了，但是命名都不规范。需要用  <code style=\\\"margin:0px 2px;padding:3px 4px;border-radius:3px;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;font-size:0.9em;background-color:rgb(246, 246, 246);\\\">cmd ren &quot;old&quot; &quot;new&quot; </code> 命令来重命名。 </p><p style=\\\"margin:1.4em 0px;\\\">--------------------------------------------</p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">7 保存批处理命令</b></h2><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">os</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 创建批处理脚本</span>\\\n<span>os</span><span style=\\\"font-weight:600;\\\">.</span><span>chdir</span><span>(</span><span>localDownloads</span><span>)</span>\\\n<span>cmd</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">open</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;_ren.bat&quot;</span><span>,</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;a&quot;</span><span>)</span>\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>truncate</span><span>()</span>\\\n\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;@echo off&quot;</span><span>)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># for item in items:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ...</span>\\\n  <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'ren &quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; &quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">-</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>filename</span><span>,</span> <span>email</span><span>,</span> <span>filename</span><span>))</span>\\\n  <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\n</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span>)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;del _ren.bat&quot;</span><span>)</span>\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>close</span><span>()</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">--------------------------------------------</p><h2 style=\\\"margin:0px;font:inherit;clear:left;margin-top:2.33333em;margin-bottom:1.16667em;font-size:1.2em;line-height:1.5;font-weight:600;\\\"><b style=\\\"font-weight:600;\\\">8 过滤主题关键词</b></h2><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\">import re\\\n\\\n# 过滤邮件主题的关键词（黑名单模式，看到某个词就跳过）\\\nignore_keys = ['不想看到的关键词A','关键词B']\\\n\\\n#...\\\n#...\\\n\\\n# 整理附件信息\\\nright_item = len(items)\\\n\\\nfor item in items:\\\n  can_download = True\\\n  fromname = item.get_attribute('fromname')\\\n  filename = item.get_attribute('filename')\\\n\\\n  for key in ignore_keys:\\\n    if re.search(key, fromname):\\\n      print('--过滤&quot;{}&quot;, 主题:{}'.format(key,fromname))\\\n      can_download = False\\\n      right_item-=1\\\n      break\\\n\\\n  for key in ignore_keys:\\\n    if re.search(key, filename):\\\n      print('--过滤&quot;{}&quot;, 附件:{}'.format(key,filename))\\\n      can_download = False\\\n      right_item-=1\\\n      break\\\n\\\n  if can_download:\\\n    ...\\\n</code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">嗯，这样就可以悠悠闲闲听着歌，翘着腿，喝着咖啡，解决所有的问题了~ </p><hr style=\\\"margin:4em auto;width:240px;max-width:100%;border-right:none;border-bottom:none;border-left:none;border-image:initial;border-top:1px solid rgb(211, 211, 211);\\\"/><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">完整代码</p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#coding:utf-8</span>\\\n\\\n<span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">re</span>\\\n<span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">os</span>\\\n<span style=\\\"font-weight:600;\\\">import</span> <span style=\\\"color:rgb(100, 100, 100);\\\">time</span>\\\n<span style=\\\"font-weight:600;\\\">from</span> <span style=\\\"color:rgb(100, 100, 100);\\\">selenium</span> <span style=\\\"font-weight:600;\\\">import</span> <span>webdriver</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#....</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 自定义参数</span>\\\n\\\n<span>url</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'https://mail.qq.com/'</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 附件下载到哪个文件夹（先提前建好，不然会报错）</span>\\\n<span>download_here</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(241, 64, 60);\\\">'D:</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\\\\</span><span style=\\\"color:rgb(241, 64, 60);\\\">Downloads</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\\\\</span><span style=\\\"color:rgb(241, 64, 60);\\\">email'</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 下载哪一页的附件(是的，每次只能下载1页)</span>\\\n<span>target_page</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 过滤邮件主题的关键词（黑名单模式，看到某个词就跳过）</span>\\\n<span>ignore_keys</span> <span style=\\\"font-weight:600;\\\">=</span> <span>[</span><span style=\\\"color:rgb(241, 64, 60);\\\">'不想看到的关键词A'</span><span>,</span><span style=\\\"color:rgb(241, 64, 60);\\\">'关键词B'</span><span>]</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#....</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 配置Web Driver</span>\\\n\\\n<span>prefs</span> <span style=\\\"font-weight:600;\\\">=</span> <span>{</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;download.default_directory&quot;</span> <span>:</span> <span>download_here</span><span>}</span>\\\n<span>options</span> <span style=\\\"font-weight:600;\\\">=</span> <span>webdriver</span><span style=\\\"font-weight:600;\\\">.</span><span>ChromeOptions</span><span>()</span>\\\n\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_argument</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;user-data-dir=selenium&quot;</span><span>)</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_argument</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'lang=zh_CN.UTF-8'</span><span>)</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_argument</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'user-agent=&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36&quot;'</span><span>)</span>\\\n<span>options</span><span style=\\\"font-weight:600;\\\">.</span><span>add_experimental_option</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;prefs&quot;</span><span>,</span><span>prefs</span><span>)</span>\\\n\\\n<span>chrome</span> <span style=\\\"font-weight:600;\\\">=</span> <span>webdriver</span><span style=\\\"font-weight:600;\\\">.</span><span>Chrome</span><span>(</span><span>options</span><span style=\\\"font-weight:600;\\\">=</span><span>options</span><span>)</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 启动Web Driver</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>get</span><span>(</span><span>url</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;Chrome启动&quot;</span><span>)</span>\\\n\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>implicitly_wait</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">3</span><span>)</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 进入附件收藏</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;folder_attach&quot;]'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>click</span><span>()</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;进入附件收藏&quot;</span><span>)</span>\\\n\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>implicitly_wait</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">3</span><span>)</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>default_content</span><span>()</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>switch_to</span><span style=\\\"font-weight:600;\\\">.</span><span>frame</span><span>(</span><span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;mainFrame&quot;]'</span><span>))</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 查看全部附件</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;empty_tips&quot;]/p/a'</span><span>)</span><span style=\\\"font-weight:600;\\\">.</span><span>click</span><span>()</span>\\\n<span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>implicitly_wait</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">3</span><span>)</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 跳转到指定的页面</span>\\\n<span style=\\\"font-weight:600;\\\">while</span> <span>target_page</span> <span style=\\\"font-weight:600;\\\">&gt;</span> <span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>:</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">list</span> <span style=\\\"font-weight:600;\\\">=</span> <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;list&quot;]/ul'</span><span>)</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">next</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">list</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;div_foot_right&quot;]/a[3]'</span><span>)</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">next</span><span style=\\\"font-weight:600;\\\">.</span><span>click</span><span>()</span>\\\n  <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;跳转页面: &quot;</span><span>,</span><span>target_page</span><span>)</span>\\\n  <span>target_page</span><span style=\\\"font-weight:600;\\\">-=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n  <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>)</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 获取附件列表</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">list</span> <span style=\\\"font-weight:600;\\\">=</span> <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>find_element_by_xpath</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'//*[@id=&quot;list&quot;]/ul'</span><span>)</span>\\\n<span>items</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">list</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_tag_name</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;li&quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;获取附件列表(</span><span style=\\\"color:rgb(241, 64, 60);\\\">%s</span><span style=\\\"color:rgb(241, 64, 60);\\\">)&quot;</span><span style=\\\"font-weight:600;\\\">%</span><span style=\\\"color:rgb(0, 132, 255);\\\">len</span><span>(</span><span>items</span><span>))</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 创建批处理脚本</span>\\\n<span>os</span><span style=\\\"font-weight:600;\\\">.</span><span>chdir</span><span>(</span><span>download_here</span><span>)</span>\\\n<span>cmd</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">open</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;_ren.bat&quot;</span><span>,</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;a&quot;</span><span>)</span>\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>seek</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0</span><span>)</span>\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>truncate</span><span>()</span>\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;@echo off&quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;创建批处理脚本&quot;</span><span>)</span>\\\n\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#....</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 整理附件信息，下载附件</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;开始整理附件：&quot;</span><span>)</span>\\\n<span>right_item</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"color:rgb(0, 132, 255);\\\">len</span><span>(</span><span>items</span><span>)</span>\\\n\\\n<span style=\\\"font-weight:600;\\\">for</span> <span>item</span> <span style=\\\"font-weight:600;\\\">in</span> <span>items</span><span>:</span>\\\n\\\n  <span>fromname</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'fromname'</span><span>)</span>\\\n  <span>filename</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filename'</span><span>)</span>\\\n  <span>can_download</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"font-weight:600;\\\">True</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">for</span> <span>key</span> <span style=\\\"font-weight:600;\\\">in</span> <span>ignore_keys</span><span>:</span>\\\n    <span style=\\\"font-weight:600;\\\">if</span> <span>re</span><span style=\\\"font-weight:600;\\\">.</span><span>search</span><span>(</span><span>key</span><span>,</span> <span>fromname</span><span>):</span>\\\n      <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'--过滤&quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;, 主题:</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>key</span><span>,</span><span>fromname</span><span>))</span>\\\n      <span>can_download</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"font-weight:600;\\\">False</span>\\\n      <span>right_item</span><span style=\\\"font-weight:600;\\\">-=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n      <span style=\\\"font-weight:600;\\\">break</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">for</span> <span>key</span> <span style=\\\"font-weight:600;\\\">in</span> <span>ignore_keys</span><span>:</span>\\\n    <span style=\\\"font-weight:600;\\\">if</span> <span>re</span><span style=\\\"font-weight:600;\\\">.</span><span>search</span><span>(</span><span>key</span><span>,</span> <span>filename</span><span>):</span>\\\n      <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'--过滤&quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;, 附件:</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>key</span><span>,</span><span>filename</span><span>))</span>\\\n      <span>can_download</span> <span style=\\\"font-weight:600;\\\">=</span> <span style=\\\"font-weight:600;\\\">False</span>\\\n      <span>right_item</span><span style=\\\"font-weight:600;\\\">-=</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span>\\\n      <span style=\\\"font-weight:600;\\\">break</span>\\\n\\\n  <span style=\\\"font-weight:600;\\\">if</span> <span>can_download</span><span>:</span>\\\n    <span>rank</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'rank'</span><span>)</span>\\\n    <span>email</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>find_elements_by_tag_name</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;span&quot;</span><span>)[</span><span style=\\\"color:rgb(0, 132, 255);\\\">1</span><span>]</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'title'</span><span>)</span>\\\n    <span>sender</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'sender'</span><span>)</span>\\\n    <span>filename</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filename'</span><span>)</span>\\\n    <span>fileextenal</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'fileextenal'</span><span>)</span>\\\n    <span>filebyte</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'filebyte'</span><span>)</span>\\\n    <span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;+&quot;</span><span>,</span><span>filename</span><span>)</span>\\\n    <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'ren &quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot; &quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">-</span><span style=\\\"color:rgb(241, 64, 60);\\\">{}</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;'</span><span style=\\\"font-weight:600;\\\">.</span><span style=\\\"color:rgb(0, 132, 255);\\\">format</span><span>(</span><span>filename</span><span>,</span> <span>email</span><span>,</span> <span>filename</span><span>))</span>\\\n    <span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span style=\\\"color:rgb(241, 64, 60);\\\">\\\\\n</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;</span><span>)</span>\\\n\\\n    <span>downurl</span> <span style=\\\"font-weight:600;\\\">=</span> <span>item</span><span style=\\\"font-weight:600;\\\">.</span><span>get_attribute</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">'downurl'</span><span>)</span>\\\n    <span>chrome</span><span style=\\\"font-weight:600;\\\">.</span><span>execute_script</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;window.open('</span><span style=\\\"color:rgb(241, 64, 60);\\\">%s</span><span style=\\\"color:rgb(241, 64, 60);\\\">');&quot;</span><span style=\\\"font-weight:600;\\\">%</span><span>downurl</span><span>)</span>\\\n    <span>time</span><span style=\\\"font-weight:600;\\\">.</span><span>sleep</span><span>(</span><span style=\\\"color:rgb(0, 132, 255);\\\">0.1</span><span>)</span>\\\n\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>write</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;del _ren.bat&quot;</span><span>)</span>\\\n<span>cmd</span><span style=\\\"font-weight:600;\\\">.</span><span>close</span><span>()</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;----&quot;</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;OK(</span><span style=\\\"color:rgb(241, 64, 60);\\\">%s</span><span style=\\\"color:rgb(241, 64, 60);\\\">)&quot;</span><span style=\\\"font-weight:600;\\\">%</span><span>right_item</span><span>)</span>\\\n<span style=\\\"color:rgb(0, 132, 255);\\\">print</span><span>(</span><span style=\\\"color:rgb(241, 64, 60);\\\">&quot;等附件全部下载好，去启动重命名脚本吧。&quot;</span><span>)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\">等待全部下载完毕后，可以到下载目录里面运行 <code style=\\\"margin:0px 2px;padding:3px 4px;border-radius:3px;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;font-size:0.9em;background-color:rgb(246, 246, 246);\\\">_run.bat</code>  就会自动在文件名前面补上发信人的QQ邮箱了。</p><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><b style=\\\"font-weight:600;\\\">...</b></p><p style=\\\"margin:1.4em 0px;\\\"><b style=\\\"font-weight:600;\\\">编辑中</b></p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span>未完待续</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/></p><hr style=\\\"margin:4em auto;width:240px;max-width:100%;border-right:none;border-bottom:none;border-left:none;border-image:initial;border-top:1px solid rgb(211, 211, 211);\\\"/><p style=\\\"margin:1.4em 0px;\\\">这里，踩坑黑历史，被抛弃的BUG (x</p><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><br/><b style=\\\"font-weight:600;\\\">车祸现场 </b>✗</p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 第一次用的时候，用item_dict输出每条信息来测试用的</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># for item in items:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict = {</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#     'rank': item.get_attribute('rank'),</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#     'email': item.find_elements_by_tag_name(&quot;span&quot;)[1].get_attribute('title'),</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#     'filename': item.get_attribute('filename'),</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#     'sender': item.get_attribute('sender'),</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   }</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   print(item_dict)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><b style=\\\"font-weight:600;\\\">车祸现场 </b>✗</p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 第二次，想着是不是该写个字典把它们都装起来呢？</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># attach_list = []</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># for item in items:</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict = {}</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict.update({'rank': item.get_attribute('rank')})</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict.update({'email': item.find_elements_by_tag_name(&quot;span&quot;)[1].get_attribute('title')})</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict.update({'sender': item.get_attribute('sender')})</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict.update({'filename': item.get_attribute('filename')})</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict.update({'fileextenal': item.get_attribute('fileextenal')})</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   item_dict.update({'filebyte':item.get_attribute('filebyte')})</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\">#   attach_list.append(item_dict)</span></code></pre></div><p style=\\\"margin:-0.8em 0px;\\\"><br/></p><p style=\\\"margin:1.4em 0px;\\\"><b style=\\\"font-weight:600;\\\">车祸现场 </b>✗</p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 写到这，我又不是要统计数据，只是想下载而已...我为啥不把他们直接写变量...搞啥字典啊</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># cmd.write('ren &quot;{}&quot; &quot;{}-{}&quot;'.format(item_dict['filename'], item_dict['email'], item_dict['filename']))</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># cmd.write(&quot;\\\\\n&quot;)</span></code></pre></div><p style=\\\"margin:1.4em 0px;\\\"><br/><b style=\\\"font-weight:600;\\\">车祸现场 </b>✗</p><div style=\\\"margin:1em 0px;\\\"><pre style=\\\"padding:0.88889em;font-size:0.9em;word-break:normal;overflow-wrap:normal;white-space:pre;overflow:auto;background:rgb(246, 246, 246);border-radius:4px;margin:0px;\\\"><code style=\\\"font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace;margin:0px;padding:0px;border-radius:0px;font-size:inherit;background-color:inherit;\\\"><span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># 模拟点击下载按钮</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># ERROR 只能下载一个文件</span>\\\n\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># item_id = item.get_attribute('id')</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># downlink = item.find_element_by_xpath(&quot;//*[@id='%s']/div/div/div[2]/div[2]/div[2]/a[1]&quot; %item_id)</span>\\\n<span style=\\\"font-style:italic;color:rgb(153, 153, 153);\\\"># downlink.click()</span></code></pre></div><p style=\\\"margin:1.4em 0px;margin-bottom:0px;\\\"><br/> </p></div></div><div style=\\\"font-size:14px;color:rgb(133, 144, 166);padding:16px 0px;overflow:hidden;width:690px;margin:0px auto;\\\">编辑于 2019-09-10</div><div style=\\\"overflow:hidden;width:690px;margin:0px auto;display:flex;\\\"><div style=\\\"display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;flex-flow:row wrap;-webkit-box-align:center;align-items:center;margin-bottom:-10px;padding:16px 0px;\\\"><div style=\\\"position:relative;display:inline-block;padding:0px 12px;color:rgb(0, 132, 255);vertical-align:top;border-radius:100px;background:rgba(0, 132, 255, 0.1);overflow:hidden;margin-bottom:10px;height:33px;font-size:13px;line-height:33px;margin-right:5px;\\\"><span><a href=\\\"https://www.zhihu.com/topic/19574431\\\" style=\\\"color:inherit;text-decoration:none;\\\" target=\\\"_blank\\\"><div style=\\\"position:relative;display:inline-block;\\\"><div>QQ 邮箱</div></div></a></span></div><div style=\\\"position:relative;display:inline-block;padding:0px 12px;color:rgb(0, 132, 255);border-radius:100px;background:rgba(0, 132, 255, 0.1);vertical-align:middle;overflow:hidden;margin-bottom:10px;height:33px;font-size:13px;line-height:33px;margin-right:5px;\\\"><span><a href=\\\"https://www.zhihu.com/topic/20086364\\\" style=\\\"color:inherit;text-decoration:none;\\\" target=\\\"_blank\\\"><div style=\\\"position:relative;display:inline-block;\\\"><div>python爬虫</div></div></a></span></div><div style=\\\"position:relative;display:inline-block;padding:0px 12px;color:rgb(0, 132, 255);border-radius:100px;background:rgba(0, 132, 255, 0.1);vertical-align:middle;overflow:hidden;margin-bottom:10px;height:33px;font-size:13px;line-height:33px;\\\"><span><a href=\\\"https://www.zhihu.com/topic/19574589\\\" style=\\\"color:inherit;text-decoration:none;\\\" target=\\\"_blank\\\"><div style=\\\"position:relative;display:inline-block;\\\"><div>Selenium</div></div></a></span></div></div></div><div style=\\\"overflow:hidden;width:690px;margin:0px auto;\\\"><div style=\\\"visibility:hidden;position:static;top:auto;right:auto;bottom:0px;left:0px;display:block;float:none;margin:0px 0px 10px;height:54px;\\\"></div></div></div></div></span></div></div></div></div></div>\\\n</div>\\\n</span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":95245}]"
metadata_diff: {"new":{"id":"10aeef8b82294070bc3a72f82ee386c3","parent_id":"061de1401cfc4cfaadf6e74e015970e9","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764345753065,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":0},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T16:12:54.465Z
created_time: 2025-11-28T16:12:54.465Z
type_: 13