{"id":445,"date":"2021-11-07T23:32:57","date_gmt":"2021-11-07T15:32:57","guid":{"rendered":"http:\/\/www.xuanchenbin.cn\/?p=445"},"modified":"2021-11-07T23:32:57","modified_gmt":"2021-11-07T15:32:57","slug":"%e6%95%99%e5%b8%88%e7%ab%af%e6%89%93%e5%8d%a1%e6%95%b0%e6%8d%ae%e8%87%aa%e5%8a%a8%e6%9b%b4%e6%96%b0-%e7%90%86%e8%ae%ba%e4%b8%8e%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"http:\/\/www.xuanchenbin.cn\/?p=445","title":{"rendered":"\u6559\u5e08\u7aef\u6253\u5361\u6570\u636e\u81ea\u52a8\u66f4\u65b0 \u7406\u8bba\u4e0e\u5b9e\u8df5"},"content":{"rendered":"<h1>\u6559\u5e08\u7aef\u6253\u5361\u6570\u636e\u81ea\u52a8\u66f4\u65b0 \u7406\u8bba\u4e0e\u5b9e\u8df5<\/h1>\n<h3>\u601d\u8def\u6d41\u7a0b<\/h3>\n<pre><code class=\"language-flow\">st=&gt;start: \u8c03\u7528chromiumdriver\n\u81ea\u52a8\u63a7\u5236chromium\nop=&gt;operation: \u6253\u5f00\u767b\u5f55\u9875\u9762\n\u8f93\u5165\u8d26\u53f7\u5bc6\u7801\u5e76\u767b\u5f55\nop1=&gt;operation: \u8c03\u7528URL\u8fdb\u5165\n\u5b66\u751f\u65e5\u62a5\u9875\u9762\n\u9650\u5236\u52a0\u8f7d\u65f6\u957f\ntime.max = 20s\ncond1=&gt;condition: try:\n\u6839\u636e\u672a\u586b\u62a5\u6309\u94ae\n\u662f\u5426\u6b63\u5e38\u53ef\u4f7f\u7528\n\u5224\u65ad\u9875\u9762\n\u662f\u5426\u52a0\u8f7d\u6210\u529f\nop2=&gt;operation: \u53d8\u91cf\u7f6e\u7a7a\n\u4ea7\u751f\u73ed\u7ea7\u5e8f\u53f7\u5217\u8868\n[1\uff0c2\uff0c3\uff0c4]\ncond2=&gt;condition: \u5224\u65ad\u662f\u5426\u5b58\u5728\n\u672a\u5b8c\u6210\u6253\u5361\u73ed\u7ea7\nop3=&gt;operation: \u5faa\u73af\u53d6\u5217\u8868\n\u9ed8\u8ba4\u73ed\u7ea7\u5e8f\u53f71~4\nop4=&gt;operation: \u6253\u5f00\u5bf9\u5e94\u73ed\u7ea7\u8be6\u7ec6\n\u672a\u5b8c\u6210\u60c5\u51b5\ncond3=&gt;condition: \u5224\u65ad\u8be5\u73ed\u7ea7\u6210\u5458\n\u662f\u5426\u5168\u90e8\u6253\u5361\u5b8c\u6210\nop5=&gt;operation: \u5220\u9664\u5bf9\u5e94\u5217\u8868\u73ed\u7ea7\u503c\nop6=&gt;operation: \u5faa\u73af\u53d6\u5bf9\u5e94\u5b66\u751f\u6570\n\u8bfb\u53d6\u5b66\u751f\u4fe1\u606f\u653e\u5165\u53d8\u91cfwhj_text\u4e2d;\ncond4=&gt;condition: \u662f\u5426\u4e3a\u6700\u540e\u4e00\u540d\u5b66\u751f\ncond5=&gt;condition: \u5224\u65ad\u5f53\u524d\u5b66\u751f\u5e8f\u53f7\n\u662f\u5426\u4e3a10\nop7=&gt;operation: \u4e0b\u4e00\u9875\ncond6=&gt;condition: \u5224\u65ad\u5faa\u73af\u662f\u5426\u7ed3\u675f\nop8=&gt;operation: \u5c06\u53d8\u91cfwhj_text\n\u653e\u5165html\u6587\u4ef6\u4e2d\n\u4f9b\u516c\u7f51\u8bbf\u95ee\nop9=&gt;operation: \u7b49\u5f85\u7247\u523b\ne=&gt;end: \u9000\u51fachromedriver\n\u8fd0\u884c\u7ed3\u675f\n\nst-&gt;op-&gt;op1-&gt;cond1\ncond1(yes)-&gt;op2-&gt;cond2\ncond1(no)-&gt;op1\ncond2(yes)-&gt;op3-&gt;op4-&gt;cond3\ncond2(no,left)-&gt;e\ncond3(yes,right)-&gt;op5(right)-&gt;op3\ncond3(no)-&gt;op6-&gt;cond6\ncond6(yes,right)-&gt;op8-&gt;op9(right)-&gt;cond2\ncond6(no)-&gt;cond4\ncond4(yes,right)-&gt;op3\ncond4(no)-&gt;cond5(yes)-&gt;op7(left)-&gt;op6\ncond5(no,left)-&gt;op6<\/code><\/pre>\n<h3>\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<pre><code class=\"language-python\">from selenium import webdriver\nimport time\n#import webbrowser\n\nif __name__ == &#039;__main__&#039;:\n    while True:\n        try:\n            wd = webdriver.Chrome(&#039;&#039;)\n            wd.get(&#039;http:\/\/ihealth.hq.gench.edu.cn\/pc\/dailys&#039;)\n            wd.implicitly_wait(10)\n            element = wd.find_element_by_id(&#039;username&#039;)\n            element.send_keys(&#039;username&#039;) #\u6b64\u5904username\u4e3a\u8d26\u53f7\n            element = wd.find_element_by_id(&#039;password&#039;)\n            element.send_keys(&#039;password\\n&#039;) #\u6b64\u5904password\u4e3a\u5bc6\u7801\n\n            wd.set_page_load_timeout(20)\n            while True:\n                try:\n                    wd.get(&#039;http:\/\/ihealth.hq.gench.edu.cn\/pc\/dailys&#039;)\n                    wd.implicitly_wait(10)\n                    wd.find_element_by_css_selector(&#039;#q-app &gt; div &gt; div.q-page-container &gt; div &gt; div.q-table__container.q-table--horizontal-separator.q-table__card.q-table--no-wrap.my-sticky-column-table &gt; div.q-table__middle.scroll &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(12) &gt; button&#039;)\n                    break\n                except:\n                    pass\n\n            whj_finish = [1, 2, 3, 4]\n            whj_text = &quot;&quot;\n            whj_message = &quot;&quot;\n            whj = [1, 2, 3, 4]\n            while sum(whj_finish) &gt; 0.5:\n                for a in whj_finish:\n                        wd.find_element_by_css_selector(&#039;#q-app &gt; div &gt; div.q-page-container &gt; div &gt; div.q-table__container.q-table--horizontal-separator.q-table__card.q-table--no-wrap.my-sticky-column-table &gt; div.q-table__middle.scroll &gt; table &gt; tbody &gt; tr:nth-child({}) &gt; td:nth-child(12) &gt; button&#039;.format(a)).click()\n                        time.sleep(2)\n                        try:\n                            i = wd.find_element_by_css_selector(&#039;body &gt; div.q-dialog.fullscreen.no-pointer-events &gt; div.q-dialog__inner.flex.no-pointer-events.q-dialog__inner--minimized.q-dialog__inner--standard.fixed-full.flex-center &gt; div &gt; div:nth-child(2) &gt; div &gt; div.q-table__bottom.row.items-center.justify-end &gt; div:nth-child(3) &gt; span&#039;).text\n                            x = int(i[len(i)-2:len(i)])\n                            whj_text = whj_text + &#039;\\n &lt;p&gt; \u4e13\u4e1a\u73ed\u7ea7-&#039; + str(a+4) + &#039;&lt;p&gt;&#039;\n                            j = 1\n                            for c in range(1,x+1):\n                                b = wd.find_element_by_css_selector(&#039;body &gt; div.q-dialog.fullscreen.no-pointer-events &gt; div.q-dialog__inner.flex.no-pointer-events.q-dialog__inner--minimized.q-dialog__inner--standard.fixed-full.flex-center &gt; div &gt; div:nth-child(2) &gt; div &gt; div.q-table__middle.scroll &gt; table &gt; tbody &gt; tr:nth-child({}) &gt; td:nth-child(3)&#039;.format(j)).text\n                                d = wd.find_element_by_css_selector(&#039;body &gt; div.q-dialog.fullscreen.no-pointer-events &gt; div.q-dialog__inner.flex.no-pointer-events.q-dialog__inner--minimized.q-dialog__inner--standard.fixed-full.flex-center &gt; div &gt; div:nth-child(2) &gt; div &gt; div.q-table__middle.scroll &gt; table &gt; tbody &gt; tr:nth-child({}) &gt; td:nth-child(7)&#039;.format(j)).text\n                                whj_text = whj_text + &#039;\\n &lt;p&gt;&#039; + b + d + &#039;&lt;p&gt;&#039;\n                                j = j + 1\n                                if j == 11:\n                                    j = 1\n                                    try:\n                                        wd.find_element_by_css_selector(&#039;body &gt; div.q-dialog.fullscreen.no-pointer-events &gt; div.q-dialog__inner.flex.no-pointer-events.q-dialog__inner--minimized.q-dialog__inner--standard.fixed-full.flex-center &gt; div &gt; div:nth-child(2) &gt; div &gt; div.q-table__bottom.row.items-center.justify-end &gt; div:nth-child(3) &gt; button.q-btn.inline.q-btn-item.non-selectable.q-btn--flat.q-btn--round.text-grey-8.q-focusable.q-hoverable.q-btn--dense &gt; div.q-btn__content.text-center.col.items-center.q-anchor--skip.justify-center.row &gt; i&#039;).click()\n                                    except:\n                                        pass\n                        except:\n                            whj.remove(a)\n                        wd.find_element_by_css_selector(&#039;body &gt; div.q-dialog.fullscreen.no-pointer-events &gt; div.q-dialog__inner.flex.no-pointer-events.q-dialog__inner--minimized.q-dialog__inner--standard.fixed-full.flex-center &gt; div &gt; div.q-card__actions.q-card__actions--horiz.row.justify-end &gt; button&#039;).click()\n                        whj_finish = whj\n\n                whj_message = whj_text\n                whj_text = &quot;&quot;\n                GEN_HTML = &quot;whj.html&quot;\n                #\u6253\u5f00\u6587\u4ef6\uff0c\u51c6\u5907\u5199\u5165\n                f = open(GEN_HTML,&#039;w&#039;)\n                message = &quot;&quot;&quot;\n                &lt;html&gt;\n                &lt;head&gt;\u672a\u5b8c\u6210\u6253\u5361\u60c5\u51b5\n                &lt;meta charset=&quot;UTF-8&quot; \/&gt;\n                &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot; \/&gt;\n                &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; \/&gt;\n                &lt;title&gt;dev.xuanchenbin.com\/whj.html&lt;\/title&gt;\n                &lt;\/head&gt;\n                &lt;body&gt;\n                &lt;p&gt;\u6bcf\u767e\u79d2\u81ea\u52a8\u66f4\u65b0&lt;p&gt;\n                &lt;p&gt;\u82e5\u663e\u793a\u65f6\u95f4\u4e0e\u5b9e\u9645\u65f6\u95f4\u4e0d\u5bf9\u7b49\u5219\u4e3a\u670d\u52a1\u5668\u6389\u7ebf\uff0c\u8bf7\u901f\u901f\u8054\u7cfb\u73ed\u52a9\uff01&lt;p&gt;\n                %s\n                %s\n                &lt;\/body&gt;\n                &lt;\/html&gt;&quot;&quot;&quot;%(whj_message,&quot;update at:&quot; + time.strftime(&quot;%Y-%m-%d-%H_%M_%S&quot;, time.localtime()))\n\n                f.write(message)\n                #\u5173\u95ed\u6587\u4ef6\n                f.close()\n                time.sleep(100)\n            wd.quit()\n            break\n        except:\n            wd.quit()<\/code><\/pre>\n<p><a href=\"http:\/\/dev.xuanchenbin.com\/whj.html\">\u4e8e20\uff1a00\u4e4b\u540e\uff0c\u70b9\u51fb\u6b64\u5904\u8bbf\u95ee\u5c55\u793a\u9875\u9762<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6559\u5e08\u7aef\u6253\u5361\u6570\u636e\u81ea\u52a8\u66f4\u65b0 \u7406\u8bba\u4e0e\u5b9e\u8df5 \u601d\u8def\u6d41\u7a0b st &hellip;<\/p>\n","protected":false},"author":1,"featured_media":448,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,7],"tags":[19,21,25],"class_list":["post-445","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-12","category-7","tag-linux","tag-python","tag-25"],"_links":{"self":[{"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=\/wp\/v2\/posts\/445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=445"}],"version-history":[{"count":0,"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=\/wp\/v2\/posts\/445\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xuanchenbin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}