無法運行時候:
selenium使用Chrome時報錯:
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
1、進入頁面
https://sites.google.com/a/chromium.org/chromedriver/home
2、選擇合適的Chrome版本下載
3、解壓下的Chromedriver放到python安裝的目錄下,
4、運行測試
from selenium import webdriver # 從selenium導入webdriver
driver = webdriver.Chrome() # Optional argument, if not specified will search path.
driver.get('https://www.baidu.com') # 獲取百度頁面
可以了,之前測試了好幾次,安裝其他目錄加到環境變量還是不行,后來放到python安裝目錄下就好了。
————————————————
版權聲明:本文為CSDN博主「奮斗吧-皮卡丘」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_42081389/article/details/88046681