Python爬虫 Selenium驱动Chrome报错selenium.common.exceptions.WebDriverException: Message

程序代码:

from selenium import webdriver


url = "http://www.baidu.com"
driver = webdriver.Chrome()
driver.get(url=url)

执行后报错:

selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"7A06D5022B2C8796268ABF79AE246C45","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=69.0.3497.81)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)

浏览器截图:
Python爬虫 Selenium驱动Chrome报错selenium.common.exceptions.WebDriverException: Message_第1张图片

出现这类报错大部分原因是浏览器和驱动版本不匹配

  1. 查看浏览器版本,最新的69版本
chrome://settings/help

Python爬虫 Selenium驱动Chrome报错selenium.common.exceptions.WebDriverException: Message_第2张图片
2. 查看google驱动对应的版本关系

https://sites.google.com/a/chromium.org/chromedriver/downloads

Python爬虫 Selenium驱动Chrome报错selenium.common.exceptions.WebDriverException: Message_第3张图片
3. 下载2.41版本的驱动,解压,放到chrome浏览器安装目录下即可

C:\Program Files (x86)\Google\Chrome\Application

再次运行程序代码:
Python爬虫 Selenium驱动Chrome报错selenium.common.exceptions.WebDriverException: Message_第4张图片

你可能感兴趣的:(Pyton)