一、安裝Selenium報錯解決
在安裝Selenium模塊的時候就報錯
ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
就試了一下pip install certifi --ignore-installed
?然后就成功了(pip install Selenium #這個Selenium的S需要大寫)
二、webdriver下載
這里需要有webdriver驅(qū)動文件
參考這個下載地址:
Release 0.32.2 · mozilla/geckodriver · GitHub
安裝了之后用下面的代碼試了一下:報錯了???
又報錯,報錯'module' object is not callable? ?模塊對象不可調(diào)用
這個時候我就知道肯定是webdriver安裝有問題,然后搜了一下要安裝瀏覽器對應版本的webdriver才可以成功運行調(diào)用,于是就卸載了selenium:pip uninstall selenium ,重新安裝對應版本的selenium:pip install selenium==3.9.0
然后參照這篇文章進行安裝對應版本的webdriver
Selenium+WebDriver 各瀏覽器驅(qū)動下載與版本對應_selenium4.8.2_公子清羽的博客-CSDN博客
1.Chrome版本查詢:
設(shè)置------關(guān)于Chrome-----可以看到版本號
安裝對應的webdriver版本即可,見下圖:
下載對應版本之后解壓并把他放到你新建的一個路徑文件夾里D:\apk\chromedriver
并把這個路徑添加到環(huán)境變量里,新建D:\apk\chromedriver,確定就行啦。
具體參考如下:
?https://zhuanlan.zhihu.com/p/52120089
?
3.安裝完成對應版本后,下面來檢驗一下是否能成功運行:
from selenium import webdriver
browser=webdriver.Chrome()
browser.get('http://www.baidu.com')
可以看到已經(jīng)可以使用webdriver驅(qū)動文件對相應的chrome進行操作文章來源:http://www.zghlxwxcb.cn/news/detail-765291.html
成功,撒花****8**88***8**********8*888*8***8?文章來源地址http://www.zghlxwxcb.cn/news/detail-765291.html
到了這里,關(guān)于安裝Selenium報錯解決&webdriver下載的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!