操作谷歌浏览器驱动下载地址
https://chromedriver.storage.googleapis.com/index.html
chrome浏览器更新速度非常快,且防不胜防,我的一下就从114更新到了119,但是国内的驱动却没有相应的更新(最新的才114)。这限制了很多想要使用selenium驱动chrome浏览器的人。
在这里推荐可以使用undetected_chromedriver库
- 下载:pip install undetected_chromedriver -i https://pypi.tuna.tsinghua.edu.cn/simp le
- 导入:import undetected_chromedriver as uc
代码展示
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get("https://www.zhihu.com/")
time.sleep(10)
作用:可以根据浏览器自动下载驱动
(除此之外,它还可以避免浏览器发现这是一个selenium驱动的程序;但是只有chrome版本)