{"id":93934,"date":"2020-04-20T06:34:46","date_gmt":"2020-04-19T22:34:46","guid":{"rendered":"http:\/\/4563.org\/?p=93934"},"modified":"2020-04-20T06:34:46","modified_gmt":"2020-04-19T22:34:46","slug":"python3-%e4%bd%bf%e7%94%a8-selenium-%e6%88%aa%e5%b1%8f%e5%90%8e%e5%86%8d%e6%88%aa%e5%8f%96%e6%8c%87%e5%ae%9a%e5%9d%90%e6%a0%87%e5%9b%be%e7%89%87%e5%ae%9a%e4%bd%8d%e4%b8%8d%e5%87%86%e7%a1%ae%e6%98%af","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=93934","title":{"rendered":"python3 \u4f7f\u7528 selenium \u622a\u5c4f\u540e\u518d\u622a\u53d6\u6307\u5b9a\u5750\u6807\u56fe\u7247\u5b9a\u4f4d\u4e0d\u51c6\u786e\u662f\u4e3a\u4ec0\u4e48"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  python3 \u4f7f\u7528 selenium \u622a\u5c4f\u540e\u518d\u622a\u53d6\u6307\u5b9a\u5750\u6807\u56fe\u7247\u5b9a\u4f4d\u4e0d\u51c6\u786e\u662f\u4e3a\u4ec0\u4e48               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : littlepython <\/span>  <span><i><\/i> 24<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u60f3\u622a\u53d6\u4e00\u4e0b\u9a8c\u8bc1\u7801\u7684\u56fe\u7247\uff0c\u4f46\u662f\u622a\u56fe\u540e\u548c\u9a8c\u8bc1\u7801\u7684\u4f4d\u7f6e\u4e0d\u5bf9\u5e94\uff0c\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u5199\u6cd5\u6709\u95ee\u9898\uff0c\u8fd8\u662f\u6709\u5176\u4f59\u7684\u56e0\u7d20\u5728\u5f71\u54cd\uff0cselenium \u7528\u7684 Chrome \u6d4f\u89c8\u5668 \u9644\u4e0a\u64cd\u4f5c\u4ee3\u7801 browser.save_screenshot(&#8216;bdbutton.png&#8217;) element = browser.find_element_by_xpath(&#8216;\/\/*[@id=&#8221;login-yzm_img&#8221;]&#8217;) # \u627e\u5230\u9a8c\u8bc1\u7801\u56fe\u7247 print(element.location) # \u6253\u5370\u5143\u7d20\u5750\u6807 print(element.size) # \u6253\u5370\u5143\u7d20\u5927\u5c0f left = element.location[&#8216;x&#8217;] top = element.location[&#8216;y&#8217;] right = element.location[&#8216;x&#8217;] + element.size[&#8216;width&#8217;] bottom = element.location[&#8216;y&#8217;] + element.size[&#8216;height&#8217;]<\/p>\n<p>im = Image.open(&#8216;bdbutton.png&#8217;) im = im.crop((left, top, right, bottom)) im.show() im.save(&#8216;bdbutton.png&#8217;)<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>11<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1179535\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ClericPy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7559\u4e2a\u7f51\u5740? \u6211\u8bd5\u8bd5\u6211\u76f4\u63a5\u539f\u751f cdp \u622a\u56fe\u51c6\u4e0d\u51c6<\/p>\n<p>\u5982\u679c\u76f2\u731c\u7684\u8bdd, \u6000\u7591\u548c\u622a\u56fe\u53c2\u6570 scale \u6709\u5173, \u4f46\u662f\u4e0d\u786e\u5b9a selenium \u8d70\u7684\u662f driver \u5185\u7f6e\u7684\u622a\u56fe\u8fd8\u662f\u4e5f\u540c\u6837\u8d70\u4e86 cdp                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179536\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : littlepython <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ClericPy \u5c31\u8292\u679c tv \u77ed\u4fe1\u767b\u5f55\u7684\u90a3\u513f\u7684\u9a8c\u8bc1\u7801\u622a\u56fe                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179537\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ClericPy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @littlepython #2 \u6d4b\u4e86\u4e0b cdp \u6293\u5230\u7684\u662f ok \u7684<\/p>\n<p>![JAHeDH.png]( https:\/\/s1.ax1x.com\/2020\/04\/16\/JAHeDH.png)<\/p>\n<p>https:\/\/paste.ubuntu.com\/p\/ZS5CZWmYsj\/                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179538\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : unixeno <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u7cfb\u7edf\u5f00\u7f29\u653e\u4e86\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179539\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dudu2017 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6307\u5b9a\u4e00\u4e2a\u7a97\u53e3\u5927\u5c0f\u8bd5\u8bd5\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179540\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : littlepython <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ClericPy \u8001\u54e5 \u4f60\u8fd9\u6bb5\u4ee3\u7801\u6211\u5728 windows \u8fd0\u884c\u76f4\u63a5\u62a5\u9519\uff0c\u6211\u662f\u6709\u4ec0\u4e48\u6ca1\u8bbe\u7f6e\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179541\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : littlepython <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @unixeno \u7cfb\u7edf\u7684\u63a8\u8350\u662f 200%\uff0c \u628a\u5750\u6807\u6539\u6210 2 \u5c31\u597d\u4e86\uff0c\u5c31\u662f\u4e0d\u77e5\u9053\u600e\u4e48\u80fd\u901a\u7528                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179542\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : littlepython <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dudu2017 \u548c\u7cfb\u7edf\u7684\u7f29\u653e\u6709\u5173 \u4e0d\u77e5\u9053\u600e\u4e48\u8bbe\u7f6e\u4e00\u4e2a\u901a\u7528\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179543\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ClericPy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @littlepython #6 \u4ee3\u7801\u5c31\u662f\u968f\u624b\u53d1\u7684, \u56e0\u4e3a\u6211\u6ca1\u7528 selenium, \u8d70\u7684\u662f\u9ed8\u8ba4\u7684 Chrome cdp, \u53ef\u4ee5\u5ffd\u7565<\/p>\n<p>\u6211\u524d\u9762\u8bf4\u7684 scale \u53c2\u6570\u5c31\u662f\u9875\u9762\u7f29\u653e\u7684\u95ee\u9898, \u4f60\u8981\u4e48\u628a scale \u6539\u4e3a 1, \u8981\u4e48\u5c31\u901a\u8fc7 selenium \u6216\u8005 js \u62ff\u5230\u5f53\u524d\u7f29\u653e scale \u503c, \u5728\u622a\u56fe\u65f6\u5019\u4f20\u5165\u6b63\u786e\u7684\u5c31\u53ef\u4ee5\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179544\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : littlepython <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ClericPy \u597d\u7684 \u6211\u8bd5\u8bd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1179545\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fzhyzamt <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Mac \u4e0b\u8bd5\u4e86\u4e00\u4e0b\u662f\u6b63\u5e38\u7684\uff0c\u53ef\u80fd\u786e\u5b9e\u662f\u7f29\u653e\u7684\u539f\u56e0                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>python3 \u4f7f\u7528 seleni&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93934"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=93934"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93934\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93934"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}