美文网首页
新版本chrome隐藏特征

新版本chrome隐藏特征

作者: 山猪打不过家猪 | 来源:发表于2021-05-29 14:56 被阅读0次
    # chrome 版本78.0.3904.70,chromedriver版本78.0.3904.70
    # 设置代理
    # chrome_options.add_argument("--proxy-server=http://58.243.205.102:4543")
    # chrome.exe --remote-debugging-port=7222  本地启动selenium
    # chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:7222")
    chrome_options = Options()
    # 设置无头
    chrome_options.add_argument("--headless")
    chrome_options.add_argument(
        'user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36')
    # 屏蔽'CHROME正受到组件控制'的提示
    chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
    # 屏蔽保存密码
    prefs = {"": ""}
    prefs["credentials_enable_service"] = False
    prefs["profile.password_manager_enabled"] = False
    chrome_options.add_experimental_option("prefs", prefs)
    driver = Chrome('./chromedriver', options=chrome_options)
    #driver.execute_script('Object.defineProperty(navigator,"webdriver",{get:() => false,});')
    #driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": """Object.defineProperty(navigator, 'webdriver', {get: () => undefined})""", })
    #driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'})
        
    driver.set_page_load_timeout(10)
    with open('./stealth.min.js') as f:
        js = f.read()
    
    driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
        "source": js
    })
    
    

    相关文章

      网友评论

          本文标题:新版本chrome隐藏特征

          本文链接:https://www.haomeiwen.com/subject/sqgysltx.html