selenium绕过爬虫检测

cooolr 于 2021-12-23 发布

去除”Chrome 正受到自动测试软件的控制。”

options.add_experimental_option('excludeSwitches', ['enable-automation'])

解决”WebDriver (New) present (failed)”

options.add_argument('--disable-blink-features=AutomationControlled')

隐藏浏览器指纹

npx extract-stealth-evasions
with open('./js/stealth.min.js') as f:
    js = f.read()

browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
    "source": js
})