from selenium import webdriver
path = "\\\\chromedriver.exe"
driver = webdriver.Chrome(executable_path=path)
option = webdriver.ChromeOptions()
option.binary_location=r'\\\\\chrome.exe'
driver = webdriver.Chrome(executable_path=path,options=option)
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": """
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
})
"""
})
driver.get("https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html")
https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html
可以判断有没有暴露webdriver
由于selenium 版本更新
新的方法为
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
尝试传参
s = Service("chromedriver.exe")
driver = webdriver.Chrome(service=s)
driver.get('https://www.baidu.com/')
driver.quit()
网友评论