【问题标题】:How to use selenium to start a specified chrome browser [duplicate]如何使用selenium启动指定的chrome浏览器[重复]
【发布时间】:2019-06-20 04:28:34
【问题描述】:
首先,我有一个 chrome 浏览器 v75(这是我每天都在使用的)。我下载了一个旧版本(v61.0),我想用它来部署 selenium 爬虫。
但问题是每次我尝试运行这个爬虫时。它始终执行 v75 版本而不是 v61.0
我已经下载了他们相应的 chromedriver 并配置了它们。
我的第一个尝试是指定告诉浏览器版本的标题。但它不起作用。
那么我应该编写一些脚本将它们添加到系统路径中吗?
PS:我想在虚拟环境中运行它,我使用的是 Mac。
【问题讨论】:
标签:
macos
selenium
chrome-web-driver
virtual-environment
【解决方案1】:
只需添加以下 chrome 选项作为选项的一部分。
这是 Python 中的解决方案:
# replace the path with the location where you have older version of chrome.exe
chrome_options = Options()
chrome_options.binary_location= "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
# load the options
driver = webdriver.Chrome(chrome_options=chrome_options)