How to initiate Chrome Canary in headless mode through Selenium and Python(如何通过 Selenium 和 Python 以无头模式启动 Chrome Canary)
问题描述
从 selenium 导入 webdriver选项 = webdriver.ChromeOptions()options.binary_location = 'C:UsersmpmccurdyDesktopGoogle Chrome Canary.lnk'options.add_argument('headless')options.add_argument('窗口大小=1200x600')驱动程序 = webdriver.Chrome(chrome_options=options)driver.get("https://www.python.org")
如果你使用 Chrome Canary 作为基础
您还可以按照文档 Chrome 二进制位置-a-Chrome-executable-in-a-non-standard-location" rel="nofollow noreferrer">在非标准位置使用 Chrome 可执行文件,如下:
从 selenium 导入 webdriver选项 = webdriver.ChromeOptions()options.binary_location = r'C:Program Files (x86)GoogleChromeApplicationchrome.exe'options.add_argument('--headless')options.add_argument('窗口大小=1200x600')driver = webdriver.Chrome(executable_path=r'C:path ochromedriver.exe', chrome_options=options)driver.get("https://www.python.org")
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = 'C:UsersmpmccurdyDesktopGoogle 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)GoogleChromeApplicationchrome.exe'
options.add_argument('--headless')
options.add_argument('window-size=1200x600')
driver = webdriver.Chrome(executable_path=r'C:path ochromedriver.exe', chrome_options=options)
driver.get("https://www.python.org")
这篇关于如何通过 Selenium 和 Python 以无头模式启动 Chrome Canary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何通过 Selenium 和 Python 以无头模式启动 Chrome Canary


- 我如何卸载 PyTorch? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01