本文介紹了如何通過(guò) Selenium 和 Python 以無(wú)頭模式啟動(dòng) Chrome Canary的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
從 selenium 導(dǎo)入 webdriver選項(xiàng) = webdriver.ChromeOptions()options.binary_location = 'C:UsersmpmccurdyDesktopGoogle Chrome Canary.lnk'options.add_argument('headless')options.add_argument('窗口大小=1200x600')驅(qū)動(dòng)程序 = webdriver.Chrome(chrome_options=options)driver.get("https://www.python.org")
解決方案
如果你使用 Chrome Canary 作為基礎(chǔ)
您還可以按照文檔 Chrome 二進(jìn)制位置-a-Chrome-executable-in-a-non-standard-location" rel="nofollow noreferrer">在非標(biāo)準(zhǔn)位置使用 Chrome 可執(zhí)行文件,如下:
從 selenium 導(dǎo)入 webdriver選項(xiàng) = 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")
這篇關(guān)于如何通過(guò) Selenium 和 Python 以無(wú)頭模式啟動(dòng) Chrome Canary的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!