{"id":72938,"date":"2026-02-06T19:42:01","date_gmt":"2026-02-06T11:42:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/72938.html"},"modified":"2026-02-06T19:42:01","modified_gmt":"2026-02-06T11:42:01","slug":"%e6%b5%8b%e8%af%95%e4%b9%8b%e8%87%aa%e5%8a%a8%e5%8c%96%e6%b5%8b%e8%af%95%e5%b8%b8%e7%94%a8%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/72938.html","title":{"rendered":"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570"},"content":{"rendered":"<h2>\u5143\u7d20\u7684\u5b9a\u4f4d<\/h2>\n<p>web\u81ea\u52a8\u5316\u6d4b\u8bd5\u7684\u64cd\u4f5c\u6838\u5fc3\u662f\u80fd\u591f\u627e\u5230\u9875\u9762\u5bf9\u5e94\u7684\u5143\u7d20&#xff0c;\u7136\u540e\u624d\u80fd\u5bf9\u5143\u7d20\u8fdb\u884c\u5177\u4f53\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u5e38\u89c1\u7684\u5143\u7d20\u5b9a\u4f4d\u65b9\u5f0f\u975e\u5e38\u591a&#xff0c;\u5982id&#xff0c;classname&#xff0c;tagname&#xff0c;xpath&#xff0c;cssSelector\u00a0<\/p>\n<p>\u5e38\u7528\u7684\u4e3b\u8981\u7531cssSelector\u548cxpath<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"885\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114147-6985d37bde820.png\" width=\"2286\" \/><\/p>\n<p>find_elements(\u65b9\u5f0f&#xff0c;\u201c\u5143\u7d20\u201d)<\/p>\n<p>from selenium import webdriver<br \/>\nfrom selenium.webdriver.chrome.service import Service as ChromeService<br \/>\nfrom selenium.webdriver.common.by import By<br \/>\nfrom webdriver_manager.chrome import ChromeDriverManager<br \/>\n#\u9a71\u52a8\u7a0b\u5e8f\u7ba1\u7406\u7684\u2f83\u52a8\u5316<br \/>\n#\u521b\u5efa\u9a71\u52a8\u5bf9\u8c61<br \/>\n#1.\u6253\u5f00\u6d4f\u89c8\u5668<br \/>\ndriver &#061;webdriver.Chrome(service&#061;ChromeService(ChromeDriverManager().install()))<br \/>\n#2.\u8f93\u2f0a\u767e\u5ea6\u2f79\u5740:https:\/\/www.baidu.com<br \/>\ndriver.get(&#034;https:\/\/www.baidu.com&#034;)<br \/>\n#3\u3001\u627e\u5230\u8f93\u2f0a\u6846\u5e76\u8f93\u2f0a\u201c\u8fea\u4e3d\u70ed\u5df4\u201d<br \/>\nret&#061;driver.find_elements(By.CSS_SELECTOR,&#034;#s-hotsearch-wrapper&#034;)<br \/>\nfor i in ret:<br \/>\n    print(i.text)<br \/>\n#5\u3001\u5173\u95ed\u6d4f\u89c8\u5668<br \/>\ndriver.quit() <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"546\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114148-6985d37ce70bd.png\" width=\"2073\" \/><\/p>\n<h3>cssSelector<\/h3>\n<p>\u9009\u62e9\u5668\u7684\u529f\u80fd&#xff1a;\u9009\u4e2d\u9875\u9762\u4e2d\u6307\u5b9a\u7684\u6807\u7b7e\u5143\u7d20<\/p>\n<p>\u9009\u62e9\u5668\u7684\u79cd\u7c7b\u5206\u4e3a\u57fa\u7840\u9009\u62e9\u5668\u548c\u590d\u5408\u9009\u62e9\u5668&#xff0c;\u5e38\u89c1\u7684\u5143\u7d20\u5b9a\u4f4d\u65b9\u5f0f\u53ef\u4ee5\u901a\u8fc7id\u9009\u62e9\u5668\u548c\u5b50\u7c7b\u9009\u62e9\u5668\u6765\u8fdb\u884c\u5b9a\u4f4d\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1032\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114149-6985d37d3a688.png\" width=\"2250\" \/><\/p>\n<h3>xpath<\/h3>\n<p>XML\u8def\u5f84\u8bed\u8a00&#xff0c;\u4e0d\u4ec5\u53ef\u4ee5\u5728XML\u6587\u4ef6\u4e2d\u67e5\u627e\u4fe1\u606f&#xff0c;\u8fd8\u53ef\u4ee5\u5728HTML\u4e2d\u9009\u53d6\u8282\u70b9\u3002<\/p>\n<p>xpath\u4f7f\u7528\u8def\u5f84\u8868\u8fbe\u5f0f\u6765\u9009\u62e9xml\u6587\u6863\u4e2d\u7684\u8282\u70b9\u3002<\/p>\n<p>\u83b7\u53d6HTML\u9875\u9762\u6240\u6709\u7684\u8282\u70b9&#xff1a;\/\/*<\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1293\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114149-6985d37d8e1da.png\" width=\"2544\" \/> <\/p>\n<p>  \u9009\u4e2d\u5f53\u524d\u9875\u9762<\/p>\n<p>\u83b7\u53d6HTML\u9875\u9762\u6307\u5b9a\u7684\u8282\u70b9&#xff1a;\/\/[\u6307\u5b9a\u8282\u70b9]<\/p>\n<ul>\n<li>\/\/ul&#xff1a;\u83b7\u53d6HTML\u9875\u9762\u6240\u6709\u7684ul\u8282\u70b9<\/li>\n<li>\/\/input&#xff1a;\u83b7\u53d6HTML\u9875\u9762\u6240\u6709\u7684input\u8282\u70b9<\/li>\n<\/ul>\n<p>\u83b7\u53d6\u2f00\u4e2a\u8282\u70b9\u4e2d\u7684\u76f4\u63a5\u5b50\u8282\u70b9&#xff1a;\/<\/p>\n<ul>\n<li>\/\/span\/input<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1266\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114149-6985d37dd1b51.png\" width=\"2559\" \/><\/p>\n<p>\u83b7\u53d6\u2f00\u4e2a\u8282\u70b9\u7684\u7236\u8282\u70b9&#xff1a;..<\/p>\n<p>\/\/input\/..\u83b7\u53d6input\u8282\u70b9\u7684\u7236\u8282\u70b9<\/p>\n<p>\u5b9e\u73b0\u8282\u70b9\u5c5e\u6027\u7684\u5339\u914d:[&#064;&#8230;]<\/p>\n<p>\/\/*[&#064;id&#061;&#039;kw&#039;]\u5339\u914dHTML\u9875\u9762\u4e2did\u5c5e\u6027\u4e3akw\u7684\u8282\u70b9<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"645\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114151-6985d37f5989d.png\" width=\"2040\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"496\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114151-6985d37fc958e.png\" width=\"2449\" \/><\/p>\n<p>\u4f7f\u7528\u6307\u5b9a\u7d22\u5f15\u7684\u65b9\u5f0f\u83b7\u53d6\u5bf9\u5e94\u7684\u8282\u70b9\u5185\u5bb9&#xff1a;<\/p>\n<p>\u6ce8\u610f&#xff1a;xpath\u7684\u7d22\u5f15\u662f\u4ece1\u5f00\u59cb\u7684\u3002\u767e\u5ea6\u9996\u9875\u901a\u8fc7&#xff1a;\/\/div\/ul\/li[3]\u5b9a\u4f4d\u5230\u7b2c\u4e09\u4e2a\u767e\u5ea6\u70ed\u641c\u6807\u7b7e&#xff1b;<\/p>\n<p>\u66f4\u4fbf\u6377\u7684\u751f\u6210selector\/xpath\u7684\u65b9\u5f0f&#xff1a;\u53f3\u952e\u9009\u62e9\u590d\u5236&#034;Copy selector\/xpath&#034;<\/p>\n<p>\u95ee\u9898&#xff1a;\u65e2\u7136\u53ef\u4ee5\u624b\u52a8\u590d\u5236 selector\/xpath\u7684\u65b9\u5f0f &#xff0c;\u4e3a\u4ec0\u4e48\u8fd8\u6709\u4e86\u89e3\u8bed\u6cd5&#xff1f;<\/p>\n<p>\u624b\u52a8\u590d\u5236\u7684selector\/xpath\u8868\u8fbe\u5f0f\u5e76\u4e0d\u2f00\u5b9a\u6ee1\u8db3\u4e0a\u9762\u7684\u552f\u2f00\u6027\u7684\u8981\u6c42&#xff0c;\u6709\u65f6\u5019\u4e5f\u9700\u8981\u624b\u52a8\u7684\u8fdb\u884c\u4fee\u6539\u8868\u8fbe\u5f0f<\/p>\n<h2>\u64cd\u4f5c\u6d4b\u8bd5\u5bf9\u8c61<\/h2>\n<p>\u83b7\u53d6\u5230\u4e86\u9875\u9762\u7684\u5143\u7d20\u4e4b\u540e&#xff0c;\u63a5\u4e0b\u6765\u5c31\u662f\u8981\u5bf9\u5143\u7d20\u8fdb\u884c\u64cd\u4f5c\u4e86\u3002\u5e38\u89c1\u7684\u64cd\u4f5c\u6709\u70b9\u51fb\u3001\u63d0\u4ea4\u3001\u8f93\u5165\u3001\u6e05 \u9664\u3001\u83b7\u53d6\u6587\u672c\u3002(\u5728python\u4e2d\u5355\u5f15\u53f7\u548c\u53cc\u5f15\u53f7\u4e0d\u533a\u5206)<\/p>\n<h3>\u70b9\u51fb\/\u63d0\u4ea4\u5bf9\u8c61<\/h3>\n<p>click()<\/p>\n<p>#\u627e\u5230\u767e\u5ea6\u2f00\u4e0b\u6309\u94ae\u5e76\u70b9\u51fb<br \/>\ndriver.find_element(By.CSS_SELECTOR, &#034;#chat-submit-button&#034;).click()<br \/>\nele&#061;driver.find_element(By.CSS_SELECTOR, &#034;#chat-submit-button&#034;)<br \/>\nele.click() <\/p>\n<h3>\u6a21\u62df\u6309\u952e\u8f93\u5165<\/h3>\n<p>send_keys(&#034;&#034;)\u00a0 \u00a0 \u00a0 \u6a21\u62df\u952e\u76d8\u8f93\u5165&#xff0c;\u952e\u76d8\u8f93\u5165\u7684\u90fd\u80fd\u6a21\u62df<\/p>\n<p>driver.find_element(By.CSS_SELECTOR, &#034;#chat-textarea&#034;).send_keys(&#034;\u8fea\u4e3d\u70ed\u5df4&#034;)<\/p>\n<p>ele.driver.find_element(By.CSS_SELECTOR, &#034;#chat-textarea&#034;)<br \/>\nele..send_keys(&#034;\u8fea\u4e3d\u70ed\u5df4&#034;) <\/p>\n<h3>\u6e05\u9664\u6587\u672c\u5185\u5bb9<\/h3>\n<p>\u8f93\u5165\u6587\u672c\u540e\u53c8\u60f3\u6362\u2f00\u4e2a\u65b0\u7684\u5173\u952e\u8bcd&#xff0c;\u8fd9\u91cc\u5c31\u9700\u8981\u7528\u5230 clear()<\/p>\n<p>\u8fde\u7eed\u7684send_keys()\u4f1a\u5c06\u591a\u6b21\u8f93\u5165\u7684\u5185\u5bb9\u62fc\u63a5\u5230\u4e00\u8d77<\/p>\n<p>driver.find_element(By.CSS_SELECTOR, &#034;#chat-textarea&#034;).send_keys(&#034;\u8fea\u4e3d\u70ed\u5df4&#034;)<br \/>\ntime.sleep(1)<br \/>\ndriver.find_element(By.CSS_SELECTOR,&#034;#chat-textarea&#034;).clear()<br \/>\ntime.sleep(1)<br \/>\ndriver.find_element(By.CSS_SELECTOR, &#034;#chat-textarea&#034;).send_keys(&#034;\u53e4\u2f12\u5a1c\u624e&#034;) <\/p>\n<h3>\u83b7\u53d6\u6587\u672c\u4fe1\u606f<\/h3>\n<p>\u5982\u679c\u5224\u65ad\u83b7\u53d6\u5230\u7684\u5143\u7d20\u5bf9\u5e94\u7684\u6587\u672c\u662f\u5426\u7b26\u5408\u9884\u671f\u5462&#xff1f;\u83b7\u53d6\u5143\u7d20\u5bf9\u5e94\u7684\u6587\u672c\u5e76\u6253\u5370\u2f00\u4e0b~~<\/p>\n<p>\u83b7\u53d6\u6587\u672c\u4fe1\u606f&#xff1a; text\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0text\u7684\u8fd4\u56de\u4fe1\u606f\u662f\u5b57\u7b26\u4e32<\/p>\n<p>text&#061;driver.find_element(By.CSS_SELECTOR,&#034;#hotsearch-content-wrapper &gt; li:nth-child(2) &gt; a &gt; span.title-content-title&#034;).text<br \/>\nprint(text) <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"78\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114152-6985d3808d798.png\" width=\"870\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"306\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114152-6985d380a40b6.png\" width=\"1587\" \/><\/p>\n<p>\u4e5f\u53ef\u4ee5\u7528assert\u8fdb\u884c\u65ad\u8a00\u68c0\u67e5\u662f\u5426\u7b26\u5408\u9884\u671f<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"960\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114153-6985d3810ccbf.png\" width=\"2066\" \/><\/p>\n<p>\u95ee\u9898&#xff1a;\u662f\u5426\u53ef\u4ee5\u901a\u8fc7 text \u83b7\u53d6\u5230\u201c\u767e\u5ea6\u2f00\u4e0b\u6309\u94ae\u201d\u4e0a\u7684\u6587\u5b57\u201c\u767e\u5ea6\u2f00\u4e0b\u201d\u5462&#xff1f;\u5c1d\u8bd5\u2f00\u4e0b<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1185\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114154-6985d3825a7c5.png\" width=\"2046\" \/> <img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"33\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114155-6985d383668db.png\" width=\"741\" \/><\/p>\n<p>\u4e4b\u524d\u662f\u4e0d\u80fd&#xff0c;\u73b0\u5728\u80fd\u4e86&#xff0c;\u4e4b\u524d\u662fvalue&#061;&#034;\u767e\u5ea6\u4e00\u4e0b&#034;value\u662f\u5c5e\u6027&#xff0c;value&#061;&#034;\u767e\u5ea6\u4e00\u4e0b&#034;\u662f\u5c5e\u6027\u503c\u6240\u4ee5\u4e0d\u80fd\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\u6587\u672c\u548c\u5c5e\u6027\u503c\u4e0d\u8981\u6df7\u6dc6\u4e86\u3002\u83b7\u53d6\u5c5e\u6027\u503c\u9700\u8981\u4f7f\u7528\u65b9\u6cd5 get_attribute(&#034;\u5c5e\u6027\u540d\u79f0&#034;) ;<\/p>\n<p>text&#061;driver.find_element(By.CSS_SELECTOR,&#034;#chat-submit-button&#034;).get_attribute(&#039;value&#039;)<br \/>\nprint(text) <\/p>\n<h3 style=\"background-color:transparent\">\u83b7\u53d6\u5f53\u524d\u9875\u9762\u6807\u9898<\/h3>\n<p>title<\/p>\n<p>title &#061; driver.title<\/p>\n<h3>\u83b7\u53d6\u5f53\u524d\u9875\u9762URL<\/h3>\n<p>current_url<\/p>\n<p>url &#061; driver.current_url<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"870\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114155-6985d38372d81.png\" width=\"2073\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"153\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114156-6985d3848ff08.png\" width=\"1233\" \/><\/p>\n<h2>\u7a97\u53e3<\/h2>\n<p>\u6253\u5f00\u2f00\u4e2a\u65b0\u7684\u9875\u9762\u4e4b\u540e\u83b7\u53d6\u5230\u7684title\u548cURL\u4ecd\u7136\u8fd8\u662f\u524d\u2f00\u4e2a\u9875\u9762\u7684&#xff1f;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1068\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114156-6985d384a9ce2.png\" width=\"1893\" \/><\/p>\n<p>\u5f53\u6211\u4eec\u624b\u5de5\u6d4b\u8bd5\u7684\u65f6\u5019&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u773c\u775b\u6765\u5224\u65ad\u5f53\u524d\u7684\u7a97\u53e3\u662f\u4ec0\u4e48&#xff0c;\u4f46\u5bf9\u4e8e\u7a0b\u5e8f\u6765\u8bf4\u5b83\u662f\u4e0d\u77e5\u9053\u5f53\u524d\u6700\u65b0\u7684\u7a97\u53e3\u5e94\u8be5\u662f\u54ea\u2f00\u4e2a\u3002\u5bf9\u4e8e\u7a0b\u5e8f\u6765\u8bf4\u5b83\u600e\u4e48\u6765\u8bc6\u522b\u6bcf\u2f00\u4e2a\u7a97\u53e3\u5462&#xff1f;\u6bcf\u4e2a\u6d4f\u89c8\u5668\u7a97\u53e3\u90fd\u6709\u2f00\u4e2a\u552f\u4e00\u7684\u5c5e\u6027\u53e5\u67c4&#xff08;handle&#xff09;\u6765\u8868\u793a&#xff0c;\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u53e5\u67c4\u6765\u5207\u6362\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"677\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114157-6985d3856c129.png\" width=\"1530\" \/><\/p>\n<h3>\u5207\u6362\u7a97\u53e3<\/h3>\n<ul>\n<li>\u83b7\u53d6\u5f53\u524d\u9875\u9762\u53e5\u67c4&#xff1a;driver.current_window_handle<\/li>\n<li>\u83b7\u53d6\u6240\u6709\u9875\u9762\u53e5\u67c4&#xff1a;\u00a0driver.window_handles<\/li>\n<li>\u5207\u6362\u5f53\u524d\u53e5\u67c4\u4e3a\u6700\u65b0\u9875\u9762&#xff1a;<\/li>\n<\/ul>\n<p>#\u83b7\u53d6\u5f53\u524d\u9875\u9762\u53e5\u67c4-\u7b2c\u4e00\u4e2a\u6807\u7b7e\u9875<br \/>\ncurhandle&#061;driver.current_window_handle<br \/>\n#\u83b7\u53d6\u6240\u6709\u53e5\u67c4<br \/>\nallhandle&#061;driver.window_handles<br \/>\n#\u904d\u5386\u6240\u6709\u53e5\u67c4&#xff0c;\u5207\u6362\u5230\u65b0\u7684\u9875\u9762<br \/>\nfor handle in allhandle:<br \/>\n    if handle !&#061; curhandle:<br \/>\n        driver.switch_to.window(handle) <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1323\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114157-6985d385b06f5.png\" width=\"2061\" \/><\/p>\n<p>\u82e5\u9875\u9762\u8df3\u8f6c\u540e\u6ca1\u6709\u6253\u5f00\u65b0\u7684\u6807\u7b7e\u9875&#xff0c;\u5219\u4e0d\u9700\u8981\u53d1\u751f\u7a97\u53e3\u7684\u5207\u6362&#xff1b;<\/p>\n<h3>\u7a97\u53e3\u8bbe\u7f6e\u5927\u5c0f<\/h3>\n<p>\u7a97\u53e3\u7684\u5927\u5c0f\u8bbe\u7f6e&#xff1a;<\/p>\n<p>#\u7a97\u2f1d\u6700\u2f24\u5316<br \/>\ndriver.maximize_window()<br \/>\n#\u7a97\u2f1d\u6700\u2f29\u5316<br \/>\ndriver.minimize_window()<br \/>\n#\u7a97\u2f1d\u5168\u5c4f<br \/>\ndriver.fullscreen_window()<br \/>\n#\u2f3f\u52a8\u8bbe\u7f6e\u7a97\u2f1d\u2f24\u2f29<br \/>\ndriver.set_window_size(1024,768) <\/p>\n<h3>\u5c4f\u5e55\u622a\u56fe<\/h3>\n<p>\u6211\u4eec\u7684\u81ea\u52a8\u5316\u811a\u672c\u2f00\u822c\u90e8\u7f72\u5728\u673a\u5668\u4e0a\u81ea\u52a8\u7684\u53bb\u8fd0\u884c&#xff0c;\u5982\u679c\u51fa\u73b0\u4e86\u62a5\u9519&#xff0c;\u6211\u4eec\u662f\u4e0d\u77e5\u9053\u7684&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u6293\u62cd\u6765\u8bb0\u5f55\u5f53\u65f6\u7684\u9519\u8bef\u573a\u666f<\/p>\n<p>driver.save_screenshot(&#039;..\/images\/image.png&#039;) <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"402\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114159-6985d38704db7.png\" width=\"1992\" \/><\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1230\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114159-6985d3874f50e.png\" width=\"1953\" \/> <\/p>\n<p>  \u8fd0\u884c\u524d\u540e<\/p>\n<p>\u4e5f\u53ef\u4ee5\u521b\u5efa\u6587\u4ef6\u5939&#xff0c;\u5728\u521b\u5efa\u7684\u6587\u4ef6\u5939\u4e0b\u5b58\u653e<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1164\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114200-6985d3882ff7d.png\" width=\"2007\" \/><\/p>\n<p>\u91cd\u540d\u6587\u4ef6\u5c06\u88ab\u8986\u76d6&#xff0c;\u90a3\u4e48\u5c06\u6bcf\u6b21\u751f\u6210\u7684\u56fe\u7247\u6587\u4ef6\u540d\u79f0\u4e0d\u4e00\u6837\u5373\u53ef(\u4ee5\u65f6\u95f4\u52a0\u540d\u79f0&#xff09;<\/p>\n<p>filename &#061; &#034;autotest-&#034;&#043;datetime.datetime.now().strftime(&#039;%Y-%m-%d-%H%M%S&#039;)&#043;&#039;.png&#039;<br \/>\n#.\/images\/autotest-2026-02-06-164656.png          \/\/\u6587\u4ef6\u540d\u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f<br \/>\ndriver.save_screenshot(&#039;.\/images\/&#039;&#043;filename) <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"666\" src=\"2026-02-06ya0kain3zi0.png\" width=\"1935\" \/><\/p>\n<h3 style=\"background-color:transparent\">\u5173\u95ed\u7a97\u53e3<\/h3>\n<p>driver.close()<\/p>\n<p>\u6ce8\u610f&#xff1a;\u7a97\u53e3\u5173\u95ed\u540edriver\u8981\u91cd\u65b0\u5b9a\u4e49&#xff1b;<\/p>\n<p>driver.quit()\u00a0 \u00a0 \u00a0 \u8868\u793a\u63a8\u51fa\u6d4f\u89c8\u5668&#xff0c;\u53ef\u80fd\u6709\u591a\u4e2a\u7a97\u53e3&#xff0c;\u6267\u884c\u540e\u6240\u6709\u7684\u6807\u7b7e\u9875\u90fd\u88ab\u5173\u95ed<\/p>\n<p>driver.close()\u00a0 \u00a0\u8868\u793a\u63a8\u51fa\u4e00\u4e2a\u7a97\u53e3<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"570\" src=\"2026-02-0655ait1mk2lg.png\" width=\"1419\" \/><\/p>\n<h2>\u5f39\u7a97<\/h2>\n<p>\u5f39\u7a97\u662f\u5728\u9875\u9762\u662f\u627e\u4e0d\u5230\u4efb\u4f55\u5143\u7d20\u7684&#xff0c;\u8fd9\u79cd\u60c5\u51b5\u600e\u4e48\u5904\u7406&#xff1f;\u4f7f\u7528selenium\u63d0\u4f9b\u7684Alert\u63a5\u53e3<\/p>\n<h3>\u8b66\u544a\u5f39\u7a97&#043;\u786e\u8ba4\u5f39\u7a97<\/h3>\n<p>\u5f39\u7a97\u5b9a\u4f4d\u4e0d\u5230\u5143\u7d20<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"229\" src=\"2026-02-061jdfbzeh1bd.png\" width=\"1181\" \/><\/p>\n<p>alert &#061; driver.switchTo.alert<br \/>\n\/\/\u786e\u8ba4<br \/>\nalert.accept()<br \/>\n\/\/\u53d6\u6d88<br \/>\nalert.dismiss() <\/p>\n<p>\u9875\u9762\u51fa\u73b0\u5f39\u7a97\u540e&#xff0c;\u5fc5\u987b\u5148\u5904\u7406\u5f39\u7a97\u540e\u624d\u80fd\u5b9a\u4f4d\u5230\u9875\u9762\u5176\u4ed6\u5143\u7d20&#xff1b;<\/p>\n<p>\u8b66\u544a\u5f39\u7a97\u65f6\u9009\u53d6accept\u548cdismiss\u90fd\u4e00\u6837&#xff0c;\u56e0\u4e3a\u53ea\u6709\u4e00\u4e2a\u9009\u9879\u53ea\u662f\u540d\u5b57\u4e0d\u540c&#xff1b;<\/p>\n<h3>\u63d0\u793a\u5f39\u7a97<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"230\" src=\"2026-02-063szrpj0rxaa.png\" width=\"565\" \/><\/p>\n<p>alert &#061; driver.switchTo.alert<br \/>\nalert.send_keys(&#034;hello&#034;)<br \/>\nalert.accept()<br \/>\nalert.dismiss() <\/p>\n<h2>\u7b49\u5f85<\/h2>\n<p>\u901a\u5e38\u4ee3\u7801\u6267\u884c\u7684\u901f\u5ea6\u6bd4\u9875\u9762\u6e32\u67d3\u7684\u901f\u5ea6\u8981\u5feb&#xff0c;\u5982\u679c\u907f\u514d\u56e0\u4e3a\u6e32\u67d3\u8fc7\u6162\u51fa\u73b0\u7684\u81ea\u52a8\u5316\u8bef\u62a5\u7684\u95ee\u9898\u5462&#xff1f;\u53ef\u4ee5\u4f7f\u7528selenium\u4e2d\u63d0\u4f9b\u7684\u4e09\u79cd\u7b49\u5f85\u65b9\u6cd5&#xff1a;<\/p>\n<h3>\u5f3a\u5236\u7b49\u5f85<\/h3>\n<p>time.sleep&#xff08;&#xff09; <\/p>\n<p>\u811a\u672c\u6267\u884c\u901f\u5ea6\u5feb&#xff0c;\u800c\u9875\u9762\u6e32\u67d3\u901f\u5ea6\u6162&#xff0c;\u5f53\u9875\u9762\u6267\u884c\u5230\u4ee3\u7801\u65f6\u9875\u9762\u8fd8\u6ca1\u6e32\u67d3\u6210\u529f\u5bfc\u81f4\u627e\u4e0d\u5230\u5143\u7d20&#xff0c;\u53ef\u4ee5\u7528sleep\u7b49\u5f85\u6e32\u67d3\u3002\u00a0\u00a0<\/p>\n<p>\u4f18\u70b9&#xff1a;\u4f7f\u7528\u7b80\u5355&#xff0c;\u8c03\u8bd5\u7684\u65f6\u5019\u6bd4\u8f83\u6709\u6548<\/p>\n<p>\u7f3a\u70b9&#xff1a;\u5f71\u54cd\u8fd0\u884c\u6548\u7387&#xff0c;\u6d6a\u8d39\u5927\u91cf\u7684\u65f6\u95f4<\/p>\n<h3>\u9690\u5f0f\u7b49\u5f85<\/h3>\n<p>\u9690\u5f0f\u7b49\u5f85\u662f\u2f00\u79cd\u667a\u80fd\u7b49\u5f85&#xff0c;\u4ed6\u53ef\u4ee5\u89c4\u5b9a\u5728\u67e5\u627e\u5143\u7d20\u65f6&#xff0c;\u5728\u6307\u5b9a\u65f6\u95f4\u5185\u4e0d\u65ad\u67e5\u627e\u5143\u7d20\u3002\u5982\u679c\u627e\u5230\u5219\u4ee3\u7801\u7ee7\u7eed\u6267\u884c&#xff0c;\u76f4\u5230\u8d85\u65f6\u6ca1\u627e\u5230\u5143\u7d20\u624d\u4f1a\u62a5\u9519\u3002<\/p>\n<p>implicitly_wait&#xff08;&#xff09; \u53c2\u6570&#xff1a;\u79d2<\/p>\n<p>\u9690\u5f0f\u7b49\u5f85\u4f5c\u7528\u57df\u662f\u6574\u4e2a\u811a\u672c\u7684\u6240\u6709\u5143\u7d20\u3002\u5373\u53ea\u8981driver\u5bf9\u8c61\u6ca1\u6709\u88ab\u91ca\u653e\u6389&#xff08; driver.quit() &#xff09;&#xff0c;\u9690 \u5f0f\u7b49\u5f85\u5c31\u2f00\u76f4\u751f\u6548\u3002\u4e00\u822c\u653e\u5728\u4ee3\u7801\u5f00\u5934\u3002<\/p>\n<p>\u4f18\u70b9&#xff1a;\u667a\u80fd\u7b49\u5f85&#xff0c;\u4f5c\u7528\u4e8e\u5168\u5c40<\/p>\n<h3>\u663e\u793a\u7b49\u5f85<\/h3>\n<p>\u663e\u793a\u7b49\u5f85\u4e5f\u662f\u2f00\u79cd\u667a\u80fd\u7b49\u5f85&#xff0c;\u5728\u6307\u5b9a\u8d85\u65f6\u65f6\u95f4\u8303\u56f4\u5185\u53ea\u8981\u6ee1\u8db3\u64cd\u4f5c\u7684\u6761\u4ef6\u5c31\u4f1a\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u4ee3\u7801\u3002(\u53ef\u4ee5\u53ea\u4f5c\u7528\u5728\u4e00\u884c\u4ee3\u7801\u4e0a)<\/p>\n<p>WebDriverWait(driver,sec).until(functions)<br \/>\n#sec  \u79d2<\/p>\n<p>functions &#xff1a;\u6d89\u53ca\u5230selenium.support.ui.ExpectedConditions\u5305\u4e0b\u7684 ExpectedConditions \u7c7b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"429\" src=\"2026-02-06ekncd0igkx4.png\" width=\"1503\" \/><\/p>\n<p>ExpectedConditions \u9884\u5b9a\u4e49\u65b9\u6cd5\u7684\u2f00\u4e9b\u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>\u65b9\u6cd5&#xff1a;title_is(title)\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/li>\n<li>\u8bf4\u660e&#xff1a;\u68c0\u67e5\u9875\u9762\u6807\u9898\u7684\u671f\u671b\u503c<\/li>\n<li>\u65b9\u6cd5&#xff1a;title_contains(title)\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/li>\n<li>\u8bf4\u660e&#xff1a;\u68c0\u67e5\u6807\u9898\u662f\u5426\u5305\u542b\u533a\u5206\u5927\u5c0f\u5199\u7684\u5b50\u5b57\u7b26\u4e32\u7684\u671f\u671b\u503c<\/li>\n<li>\u65b9\u6cd5&#xff1a;visibility_of_element_located(locator, str])<\/li>\n<li>\u8bf4\u660e&#xff1a;\u68c0\u67e5\u5143\u7d20\u662f\u5426\u5b58\u5728\u4e8e\u9875\u9762\u7684DOM\u4e0a\u5e76\u4e14\u53ef\u89c1\u7684\u671f\u671b\u503c\u3002<\/li>\n<li>\u65b9\u6cd5&#xff1a;presence_of_element_located&#xff08;locator&#xff0c; str]&#xff09;<\/li>\n<li>\u8bf4\u660e&#xff1a;\u7528\u4e8e\u68c0\u67e5\u5143\u7d20\u662f\u5426\u5b58\u5728\u4e8e\u9875\u9762\u7684DOM\u4e0a\u7684\u671f\u671b\u503c<\/li>\n<li>\u65b9\u6cd5&#xff1a;visibility_of&#xff08;element&#xff09;<\/li>\n<li>\u8bf4\u660e&#xff1a;\u68c0\u67e5\u5df2\u77e5\u5b58\u5728\u4e8e\u9875\u9762DOM\u4e0a\u7684\u5143\u7d20\u662f\u5426\u53ef\u89c1\u7684\u671f\u671b<\/li>\n<li>\u65b9\u6cd5&#xff1a;visibility_of&#xff08;element&#xff09;<\/li>\n<li>\u8bf4\u660e&#xff1a;<span style=\"color:#fe2c24\">\u68c0\u67e5\u662f\u5426\u51fa\u73b0\u5f39\u7a97<\/span><\/li>\n<\/ul>\n<p>\u9690\u5f0f\u7b49\u5f85\u65e0\u6cd5\u7b49\u5f85\u5f39\u7a97&#xff0c;\u56e0\u4e3a\u5f39\u7a97\u4e0d\u662f\u9875\u9762\u5143\u7d20&#xff0c;\u65e0\u6cd5\u901a\u8fc7\u9875\u9762\u5143\u7d20\u6765\u5b9a\u4f4d\u3002\u663e\u793a\u7b49\u5f85\u53ef\u4ee5\u5904\u7406\u3002<\/p>\n<p>\u4f18\u70b9&#xff1a;\u663e\u793a\u7b49\u5f85\u662f\u667a\u80fd\u7b49\u5f85&#xff0c;\u53ef\u4ee5\u81ea\u5b9a\u4e49\u663e\u793a\u7b49\u5f85\u7684\u6761\u4ef6&#xff0c;\u64cd\u4f5c\u7075\u6d3b<\/p>\n<p>\u7f3a\u70b9&#xff1a;\u5199\u6cd5\u590d\u6742<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1242\" src=\"2026-02-065cngxszr5m3.png\" width=\"2031\" \/><\/p>\n<p>\u4e0d\u5efa\u8bae\u663e\u793a\u7b49\u5f85\u548c\u9690\u5f0f\u7b49\u5f85\u4e00\u8d77\u51fa\u73b0\u3002\u5f53\u627e\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u5143\u7d20\u65f6\u5019\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e0d\u53ef\u9884\u6d4b\u7684\u7b49\u5f85\u65f6\u95f4<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1467\" src=\"2026-02-06tazcpdlfeh3.png\" width=\"2099\" \/><\/p>\n<h2>\u6d4f\u89c8\u5668\u5bfc\u822a<\/h2>\n<p>\u5e38\u89c1\u64cd\u4f5c&#xff1a;<\/p>\n<li>\u6253\u5f00\u7f51\u7ad9&#xff1a;driver.get(&#034;https:\/\/tool.lu\/&#034;)\u00a0 \u00a0 \u00a0 \u4efb\u610f\u7f51\u7ad9\u90fd\u884c<\/li>\n<li>\u6d4f\u89c8\u5668\u7684\u524d\u8fdb\u3001\u540e\u9000\u3001\u5237\u65b0&#xff1a;driver.back() driver.forward() driver.refresh()<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"258\" src=\"2026-02-06vjnecdudfsr.png\" width=\"1686\" \/><\/p>\n<p>\u6848\u4f8b&#xff1a;\u767e\u5ea6\u9996\u9875\u6d4b\u8bd5https:\/\/tool.lu\/\u6807\u7b7e\u5165\u53e3<\/p>\n<h2>\u6587\u4ef6\u4e0a\u4f20<\/h2>\n<p>\u70b9\u51fb\u6587\u4ef6\u4e0a\u4f20\u7684\u573a\u666f\u4e0b\u4f1a\u5f39\u7a97\u7cfb\u7edf\u7a97\u53e3&#xff0c;\u8fdb\u884c\u6587\u4ef6\u7684\u9009\u62e9\u3002<\/p>\n<p>\u5f53\u901a\u8fc7\u9875\u9762\u5143\u7d20\u8c03\u8d77\u4e0a\u4f20\u7684\u7a97\u53e3\u540e&#xff0c;\u6587\u4ef6\u7a97\u53e3\u4e0d\u80fd\u4f5c\u4e3a\u9875\u9762\u5143\u7d20\u9009\u4e2d\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"972\" src=\"2026-02-06ttpky21vphl.png\" width=\"2340\" \/><\/p>\n<p>selenium\u65e0\u6cd5\u8bc6\u522b\u975eweb\u7684\u63a7\u4ef6&#xff0c;\u4e0a\u4f20\u6587\u4ef6\u7a97\u53e3\u4e3a\u7cfb\u7edf\u81ea\u5e26&#xff0c;\u65e0\u6cd5\u8bc6\u522b\u7a97\u53e3\u5143\u7d20&#xff0c;\u4f46\u662f\u53ef\u4ee5\u4f7f\u7528sendkeys\u6765\u4e0a\u4f20\u6307\u5b9a\u8def\u5f84\u7684\u6587\u4ef6&#xff0c;\u8fbe\u5230\u7684\u6548\u679c\u662f\u4e00\u6837\u7684\u3002\u901a\u8fc7send_keys()\u5c06\u672c\u5730\u7684\u6587\u4ef6(\u8def\u5f84\u52a0\u6587\u4ef6\u540d)\u4e0a\u4f20<\/p>\n<p>ele &#061; driver.find_element(By.CSS_SELECTOR,&#034;body &gt; div &gt; div &gt;<br \/>\ninput[type&#061;file]&#034;)<br \/>\nele.send_keys(&#034;D:\\\\\\\\file\\\\\\\\test.txt&#034;) <\/p>\n<h2>\u6d4f\u89c8\u5668\u53c2\u6570\u8bbe\u7f6e<\/h2>\n<p>\u8bbe\u7f6e\u65e0\u5934\u6a21\u5f0f&#xff1a;<\/p>\n<p>\u65e0\u5934\u6a21\u5f0f&#xff1a;\u7a0b\u5e8f\u5728\u540e\u7aef\u8fd0\u884c&#xff0c;\u754c\u9762\u770b\u4e0d\u5230\u9875\u9762\u7684\u8868\u73b0\u3002\u770b\u4e0d\u5230\u6267\u884c\u7684\u8fc7\u7a0b<\/p>\n<p>options &#061; webdriver.ChromeOptions()<br \/>\noptions.add_argument(&#034;-headless&#034;)   \/\/\u8bbe\u7f6e\u53c2\u6570  -headless&#xff1a;\u65e0\u5934\u6a21\u5f0f   \u4e0d\u8bbe\u53c2\u6570\u9ed8\u8ba4\u6709\u5934\u6a21\u5f0f<br \/>\ndriver &#061;webdriver.Chrome(service&#061;ChromeService(ChromeDriverManager().install()), options&#061;options) <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1466\" src=\"2026-02-06gd3uxnpfquh.png\" width=\"2091\" \/><\/p>\n<p>\u770b\u4e0d\u5230\u6d4f\u89c8\u5668\u6253\u5f00\u7684\u8fc7\u7a0b&#xff1b;<\/p>\n<p>\u9875\u9762\u52a0\u8f7d\u7b56\u7565&#xff1a;<\/p>\n<p>options.page_load_strategy &#061; &#039;\u52a0\u8f7d\u2f45\u5f0f&#039; <\/p>\n<p>driver.get()\u4f1a\u9ed8\u8ba4\u7b49\u5230\u8d44\u6e90\u52a0\u8f7d\u5b8c\u6210\u624d\u4f1a\u7ee7\u7eed\u5f80\u4e0b\u6267\u884c&#xff0c;\u4f46\u5b9e\u9645\u4e0a\u4e3b\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u4e4b\u540e\u5c31\u53ef\u4ee5\u7ee7\u7eed\u6267\u884c\u81ea\u52a8\u5316&#xff0c;\u82e5\u4e00\u76f4\u7b49\u5f85\u7684\u8bdd\u4f1a\u5bfc\u81f4\u9875\u9762\u8d85\u65f6&#xff0c;\u5143\u7d20\u627e\u4e0d\u5230\u95ee\u9898\u7b49<\/p>\n<p>\u9875\u9762\u52a0\u8f7d\u65b9\u5f0f\u4e3b\u8981\u6709\u4e09\u79cd\u7c7b\u578b&#xff1a;<\/p>\n<ul>\n<li>\u7b56\u7565&#xff1a;normal<\/li>\n<li>\u8bf4\u660e&#xff1a;\u9ed8\u8ba4\u503c,\u7b49\u5f85\u6240\u6709\u8d44\u6e90\u4e0b\u8f7d<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"299\" src=\"2026-02-06pnss4bt0oce.png\" width=\"1113\" \/><\/li>\n<li>\u7b56\u7565&#xff1a;eager<\/li>\n<li>\u8bf4\u660e&#xff1a;DOM\u8bbf\u95ee\u5df2\u51c6\u5907\u5c31\u7eea,\u4f46\u8bf8\u5982\u56fe\u50cf\u7684\u5176\u4ed6\u8d44\u6e90\u53ef\u80fd\u4ecd\u5728\u52a0\u8f7d<\/li>\n<li>\u7b56\u7565&#xff1a;none<\/li>\n<li>\u8bf4\u660e&#xff1a;\u5b8c\u5168\u4e0d\u4f1a\u963b\u585eWebDriver<\/li>\n<\/ul>\n<p>options &#061; webdriver.ChromeOptions()<br \/>\noptions.page_load_strategy &#061; &#039;eager&#039;<br \/>\ndriver &#061; webdriver.Chrome(service&#061;ChromeService(ChromeDriverManager().install()),options&#061;options)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5143\u7d20\u7684\u5b9a\u4f4d<br \/>\nweb\u81ea\u52a8\u5316\u6d4b\u8bd5\u7684\u64cd\u4f5c\u6838\u5fc3\u662f\u80fd\u591f\u627e\u5230\u9875\u9762\u5bf9\u5e94\u7684\u5143\u7d20&#xff0c;\u7136\u540e\u624d\u80fd\u5bf9\u5143\u7d20\u8fdb\u884c\u5177\u4f53\u7684\u64cd\u4f5c\u3002<br \/>\n\u5e38\u89c1\u7684\u5143\u7d20\u5b9a\u4f4d\u65b9\u5f0f\u975e\u5e38\u591a&#xff0c;\u5982id&#xff0c;classname&#xff0c;tagname&#xff0c;xpath&#xff0c;cssSelector\u00a0<br \/>\n\u5e38\u7528\u7684\u4e3b\u8981\u7531cssSelector\u548cxpath find_elements(\u65b9\u5f0f&#xff0c;\u201c\u5143\u7d20\u201d) from selenium import webdriver<br \/>\nfrom sel<\/p>\n","protected":false},"author":2,"featured_media":72918,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,3789],"topic":[],"class_list":["post-72938","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-python","tag-3789"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/72938.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5143\u7d20\u7684\u5b9a\u4f4d web\u81ea\u52a8\u5316\u6d4b\u8bd5\u7684\u64cd\u4f5c\u6838\u5fc3\u662f\u80fd\u591f\u627e\u5230\u9875\u9762\u5bf9\u5e94\u7684\u5143\u7d20&#xff0c;\u7136\u540e\u624d\u80fd\u5bf9\u5143\u7d20\u8fdb\u884c\u5177\u4f53\u7684\u64cd\u4f5c\u3002 \u5e38\u89c1\u7684\u5143\u7d20\u5b9a\u4f4d\u65b9\u5f0f\u975e\u5e38\u591a&#xff0c;\u5982id&#xff0c;classname&#xff0c;tagname&#xff0c;xpath&#xff0c;cssSelector\u00a0 \u5e38\u7528\u7684\u4e3b\u8981\u7531cssSelector\u548cxpath find_elements(\u65b9\u5f0f&#xff0c;\u201c\u5143\u7d20\u201d) from selenium import webdriver from sel\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/72938.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-06T11:42:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114147-6985d37bde820.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72938.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/72938.html\",\"name\":\"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-06T11:42:01+00:00\",\"dateModified\":\"2026-02-06T11:42:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/72938.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/72938.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72938.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/72938.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5143\u7d20\u7684\u5b9a\u4f4d web\u81ea\u52a8\u5316\u6d4b\u8bd5\u7684\u64cd\u4f5c\u6838\u5fc3\u662f\u80fd\u591f\u627e\u5230\u9875\u9762\u5bf9\u5e94\u7684\u5143\u7d20&#xff0c;\u7136\u540e\u624d\u80fd\u5bf9\u5143\u7d20\u8fdb\u884c\u5177\u4f53\u7684\u64cd\u4f5c\u3002 \u5e38\u89c1\u7684\u5143\u7d20\u5b9a\u4f4d\u65b9\u5f0f\u975e\u5e38\u591a&#xff0c;\u5982id&#xff0c;classname&#xff0c;tagname&#xff0c;xpath&#xff0c;cssSelector\u00a0 \u5e38\u7528\u7684\u4e3b\u8981\u7531cssSelector\u548cxpath find_elements(\u65b9\u5f0f&#xff0c;\u201c\u5143\u7d20\u201d) from selenium import webdriver from sel","og_url":"https:\/\/www.wsisp.com\/helps\/72938.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-06T11:42:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260206114147-6985d37bde820.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/72938.html","url":"https:\/\/www.wsisp.com\/helps\/72938.html","name":"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-06T11:42:01+00:00","dateModified":"2026-02-06T11:42:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/72938.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/72938.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/72938.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6d4b\u8bd5\u4e4b\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u51fd\u6570"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=72938"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72938\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/72918"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=72938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=72938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=72938"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=72938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}