1
from selenium import webdriver

options = webdriver.ChromeOptions()
options.binary_location = 'C:\Users\mpmccurdy\Desktop\Google Chrome Canary.lnk'
options.add_argument('headless')
options.add_argument('window-size=1200x600')
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://www.python.org")
4

2 回答 2

0

如果您使用Chrome Canary作为基本要求,服务器仍然希望您根据底层操作系统架构将Chrome安装在默认位置,如下所示:

Chrome_binary_expected_location

您还可以按照文档在非标准位置使用 Chrome 可执行文件覆盖默认的Chrome 二进制位置,如下所示:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.binary_location = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
options.add_argument('--headless')
options.add_argument('window-size=1200x600')
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
driver.get("https://www.python.org")
于 2018-05-30T15:33:58.700 回答
0
chrome_options = Options()
chrome_options.add_argument("--headless")
path = os.getcwd() +'\\chromedriver.exe' #needs to be in your current working directory
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=path)
于 2018-05-30T14:42:20.433 回答