python3.6中使用selenium + chromedriver访问Chrome浏览器时报错

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 
if __name__ == '__main__':
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    driver_path = 'E:\Program Files (x86)\python\Scripts\chromedriver.exe'    #这里放的就是下载的chromedriver本地路径
    driver = webdriver.Chrome(chrome_options=chrome_options, executable_path = driver_path)
    driver.get('https://www.toutiao.com/ch/news_tech/')
    driver.quit()

下面是报错信息:python

 

这里的错误信息就是chrome浏览器的版本与chromediver的版本不一致形成的web

解决办法就是找到与你电脑chrome浏览器对应的chromediver就能够解决这个问题了,chrome

咱们进入到chromedriver的下载地址:http://npm.taobao.org/mirrors/chromedrivernpm

网页的内容以下图:浏览器

咱们随便进入一个目录找到这个文件打开:less

咱们就能够找到版本之间的对应关系了ui

相关文章
相关标签/搜索