如何通过Selenium和Python以无头模式启动Chrome Canary [英] How to initiate Chrome Canary in headless mode through Selenium and Python

查看:116
本文介绍了如何通过Selenium和Python以无头模式启动Chrome Canary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从硒导入Webdriver的

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

解决方案

如果您使用 Chrome Canary 作为基本的

您还可以按照文档

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")

If you are using Chrome Canary as a basic Requirement the server still expects you to have Chrome installed in the default location as per the underlying OS architecture as follows:

You can also override the default Chrome Binary Location following the documentation Using a Chrome executable in a non-standard location as follows:

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")

这篇关于如何通过Selenium和Python以无头模式启动Chrome Canary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆