{"id":322,"date":"2025-05-30T17:39:10","date_gmt":"2025-06-04T10:09:09","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=322"},"modified":"2025-06-04T17:39:10","modified_gmt":"2025-06-04T10:09:09","slug":"python-selenium-%e7%b9%9e%e9%81%8e%e9%80%99%e5%80%8b%e7%80%8f%e8%a6%bd%e5%99%a8%e6%88%96%e6%87%89%e7%94%a8%e7%a8%8b%e5%bc%8f%e5%8f%af%e8%83%bd%e6%9c%89%e5%ae%89%e5%85%a8%e7%96%91%e6%85%ae","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/python\/python-selenium-%e7%b9%9e%e9%81%8e%e9%80%99%e5%80%8b%e7%80%8f%e8%a6%bd%e5%99%a8%e6%88%96%e6%87%89%e7%94%a8%e7%a8%8b%e5%bc%8f%e5%8f%af%e8%83%bd%e6%9c%89%e5%ae%89%e5%85%a8%e7%96%91%e6%85%ae\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Python Selenium \u7e5e\u904e Google \u7684\u5b89\u5168\u9a57\u8b49\u9650\u5236"},"content":{"rendered":"<h1>\u5982\u4f55\u4f7f\u7528 Python Selenium \u7e5e\u904e Google \u7684\u5b89\u5168\u9a57\u8b49\u9650\u5236<\/h1>\n<h2>\u4ecb\u7d39<\/h2>\n<p>\u5728\u4f7f\u7528 Selenium \u81ea\u52d5\u5316\u6e2c\u8a66\u6216\u7db2\u9801\u722c\u87f2\u6642\uff0c\u53ef\u80fd\u6703\u9047\u5230 Google \u7684\u5b89\u5168\u9a57\u8b49\u63d0\u793a\uff0c\u986f\u793a\u300c\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\u300d\u3002\u9019\u7bc7\u6587\u7ae0\u5c07\u4ecb\u7d39\u5982\u4f55\u900f\u904e\u7279\u5b9a\u7684 URL \u7e5e\u904e\u9019\u4e00\u9650\u5236\uff0c\u4e26\u63d0\u4f9b 2025 \u5e74\u6700\u65b0\u7684 Python \u8a9e\u6cd5\u53ca\u6700\u4f73\u5be6\u8e10\u3002<\/p>\n<h2>Selenium \u88ab Google \u963b\u64cb\u7bc4\u4f8b<\/h2>\n<p>\u7576\u4f7f\u7528 WebDriver \u958b\u555f\u700f\u89bd\u5668\u6642\uff0cGoogle \u6703\u5c07\u9019\u8996\u70ba\u6f5b\u5728\u7684\u5b89\u5168\u98a8\u96aa\uff0c\u4e26\u963b\u6b62\u7528\u6236\u767b\u5165\u3002\u9019\u88e1\u5c07\u5c55\u793a\u5982\u4f55\u4f7f\u7528 Selenium \u4f86\u958b\u555f Google \u9996\u9801\u4e26\u9032\u884c\u767b\u5165\u3002<\/p>\n<h3>\u7a0b\u5f0f\u78bc\u793a\u4f8b<\/h3>\n<p>&#8220;`python<br \/>\nfrom selenium import webdriver<br \/>\nfrom webdriver_manager.chrome import ChromeDriverManager<\/p>\n<p># \u4f7f\u7528 Chrome \u7684 WebDriver<br \/>\nbrowser = webdriver.Chrome(ChromeDriverManager().install())<\/p>\n<p># \u958b\u555f Google \u9996\u9801<br \/>\nbrowser.get(&#8216;https:\/\/www.google.com&#8217;)<br \/>\n&#8220;`<\/p>\n<h3>\u958b\u555f\u767b\u5165<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/\u622a\u5716-2020-11-05-\u4e0a\u534810.04.30-275x300.png\" alt=\"\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\" title=\"\"><br \/>\n*\u5716\u793a\uff1a\u767b\u5165\u9801\u9762\u622a\u5716*<\/p>\n<h3>\u767b\u5165\u7d50\u679c<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/\u622a\u5716-2020-11-05-\u4e0a\u53489.49.03-300x160.png\" alt=\"\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\" title=\"\"><br \/>\n*\u5716\u793a\uff1a\u767b\u5165\u5931\u6557\u63d0\u793a*<\/p>\n<p>\u7121\u6cd5\u5c07\u60a8\u767b\u5165\uff0c\u56e0\u70ba\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\u3002\u5efa\u8b70\u60a8\u6539\u7528\u5176\u4ed6\u700f\u89bd\u5668\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u7cfb\u7d71\u652f\u63f4\u7684\u700f\u89bd\u5668\uff0c\u8acb\u91cd\u65b0\u6574\u7406\u756b\u9762\uff0c\u7136\u5f8c\u518d\u6b21\u5617\u8a66\u767b\u5165\u5e33\u6236\u3002<\/p>\n<h2>\u7e5e\u904e\u5b89\u5168\u9650\u5236\u7684\u89e3\u6c7a\u65b9\u6cd5<\/h2>\n<p>\u8981\u7e5e\u904e Google \u7684\u5b89\u5168\u6027\u9650\u5236\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7684 OAuth 2.0 \u6388\u6b0a URL\uff1a<\/p>\n<blockquote><p>\n  https:\/\/accounts.google.com\/o\/oauth2\/v2\/auth\/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&#038;prompt=consent&#038;response_type=code&#038;client_id=407408718192.apps.googleusercontent.com&#038;scope=email&#038;access_type=offline&#038;flowName=GeneralOAuthFlow\n<\/p><\/blockquote>\n<h3>\u7a0b\u5f0f\u78bc\u793a\u4f8b<\/h3>\n<p>&#8220;`python<br \/>\nfrom selenium import webdriver<br \/>\nfrom webdriver_manager.chrome import ChromeDriverManager<\/p>\n<p># \u4f7f\u7528 Chrome \u7684 WebDriver<br \/>\nbrowser = webdriver.Chrome(ChromeDriverManager().install())<br \/>\nbrowser.get(&#8216;https:\/\/accounts.google.com\/o\/oauth2\/v2\/auth\/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&#038;prompt=consent&#038;response_type=code&#038;client_id=407408718192.apps.googleusercontent.com&#038;scope=email&#038;access_type=offline&#038;flowName=GeneralOAuthFlow&#8217;)<br \/>\n&#8220;`<\/p>\n<h3>\u767b\u5165\u756b\u9762<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/\u622a\u5716-2020-11-05-\u4e0a\u53489.59.36-264x300.png\" alt=\"\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\" title=\"\"><br \/>\n*\u5716\u793a\uff1aGoogle OAuth 2.0 Playground \u767b\u5165\u756b\u9762*<\/p>\n<h3>\u767b\u5165\u7d50\u679c<\/h3>\n<p>\u767b\u5165\u6210\u529f\u5f8c\uff0c\u5c07\u8df3\u8f49\u5230 Google Developer \u9801\u9762\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/\u622a\u5716-2020-11-05-\u4e0a\u534810.07.38-300x189.png\" alt=\"\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\" title=\"\"><br \/>\n*\u5716\u793a\uff1a\u6210\u529f\u767b\u5165\u5f8c\u7684\u9801\u9762*<\/p>\n<h2>\u5ef6\u4f38\u61c9\u7528<\/h2>\n<p>\u6b64\u6280\u8853\u53ef\u4ee5\u5e6b\u52a9\u7528\u6236\u6210\u529f\u767b\u5165 Google \u670d\u52d9\uff0c\u800c\u4e0d\u50c5\u9650\u65bc Google \u9996\u9801\u3002\u60a8\u53ef\u4ee5\u900f\u904e\u9019\u4e00\u65b9\u6cd5\u8a2a\u554f YouTube\u3001Gmail \u7b49\u5176\u4ed6 Google \u670d\u52d9\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/jPk9SIY.gif\" alt=\"\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\" title=\"\"><br \/>\n*\u52d5\u756b\u793a\u7bc4\uff1a\u8df3\u8f49\u5230\u5176\u4ed6 Google \u670d\u52d9*<\/p>\n<h2>\u539f\u7406\u89e3\u6790<\/h2>\n<p>\u76ee\u524d Google \u5c0d WebDriver \u7684\u767b\u5165\u9032\u884c\u4e86\u9650\u5236\uff0c\u4f46\u5141\u8a31\u901a\u904e\u7b2c\u4e09\u65b9\u61c9\u7528\u4f86\u9032\u884c\u767b\u5165\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u5728 Stack Overflow \u4e0a\u4f7f\u7528 Google \u767b\u5165\uff0c\u6210\u529f\u5f8c\u5c07\u6703\u5728 Google \u5e33\u6236\u4e2d\u767b\u9304\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/\u622a\u5716-2020-11-05-\u4e0a\u534810.27.46-300x198.png\" alt=\"\u9019\u500b\u700f\u89bd\u5668\u6216\u61c9\u7528\u7a0b\u5f0f\u53ef\u80fd\u6709\u5b89\u5168\u7591\u616e\" title=\"\"><br \/>\n*\u5716\u793a\uff1a\u7b2c\u4e09\u65b9\u61c9\u7528\u767b\u5165\u793a\u7bc4*<\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u900f\u904e\u9019\u7a2e\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u65b9\u4fbf\u5730\u7e5e\u904e Google \u7684\u5b89\u5168\u9a57\u8b49\u9650\u5236\uff0c\u4e26\u4f7f\u7528\u5404\u7a2e Google \u670d\u52d9\u3002\u9019\u662f\u81ea\u52d5\u5316\u6e2c\u8a66\u6216\u7db2\u9801\u722c\u87f2\u7684\u5be6\u7528\u6280\u5de7\u3002<\/p>\n<p>\u53c3\u8003\u8cc7\u6599\uff1a[\u5982\u4f55\u4f7f\u7528 Python \u9032\u884c\u7db2\u9801\u81ea\u52d5\u5316](https:\/\/vocus.cc\/article\/600aaf8fd43b87001c3fa1f1)<\/p>\n<h2>Q&#038;A\uff08\u5e38\u898b\u554f\u984c\u89e3\u7b54\uff09<\/h2>\n<h3>Q1: \u4f7f\u7528 Selenium \u7e5e\u904e Google \u9a57\u8b49\u6709\u98a8\u96aa\u55ce\uff1f<\/h3>\n<p>A1: \u662f\u7684\uff0c\u4f7f\u7528\u6b64\u65b9\u6cd5\u53ef\u80fd\u9055\u53cd Google \u7684\u4f7f\u7528\u689d\u6b3e\uff0c\u5efa\u8b70\u50c5\u5728\u5408\u6cd5\u7bc4\u570d\u5167\u4f7f\u7528\u3002<\/p>\n<h3>Q2: \u5982\u4f55\u8655\u7406\u767b\u5165\u5931\u6557\u7684\u60c5\u6cc1\uff1f<\/h3>\n<p>A2: \u78ba\u4fdd\u4f7f\u7528\u7684 URL \u548c\u53c3\u6578\u6b63\u78ba\uff0c\u4e26\u6aa2\u67e5\u60a8\u7684\u7db2\u7d61\u9023\u63a5\u3002<\/p>\n<h3>Q3: \u6709\u5176\u4ed6\u65b9\u5f0f\u53ef\u4ee5\u9032\u884c\u81ea\u52d5\u5316\u6e2c\u8a66\u55ce\uff1f<\/h3>\n<p>A3: \u9664\u4e86 Selenium\uff0c\u60a8\u9084\u53ef\u4ee5\u8003\u616e\u4f7f\u7528\u5176\u4ed6\u5de5\u5177\u5982 Puppeteer \u6216 Playwright\u3002<\/p>\n<p>&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u4f60\u662f\u7528webdriver\u6240\u958b\u555f\u7684\u700f\u89bd\u5668<br \/>\nGoogle\u767b\u5165\u4e00\u5f8b\u7576\u4f5c\u4f60\u8981\u505a\u58de\u4e8b<br \/>\n\u6703\u9032\u884c\u767b\u5165\u963b\u64cb<br \/>\n\u53eb\u4f60\u53bb\u7528\u6b63\u5e38\u700f\u89bd\u5668\u767b\u5165<br \/>\n\u4e0b\u9762\u662fselenium\u7bc4\u4f8b<br \/>\nChrome\u8ddfSafari \u6211\u8a66\u904e\u90fd\u6703\u88ab\u64cb<\/p>\n","protected":false},"author":1,"featured_media":325,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18],"tags":[42,86,84,85],"class_list":["post-322","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-python","tag-google","tag-google-login","tag-selenium","tag-webdriver","post_format-post-format-aside"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/\u622a\u5716-2020-11-05-\u4e0a\u534810.04.30.png","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-5c","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":10,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":13077,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/322\/revisions\/13077"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media\/325"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}