最新解决navigator.webdriver=true的方法

selenium

browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
    "source": """
    Object.defineProperty(navigator, 'webdriver', {
      get: () => undefined
    })
  """
})

 

pyppeteer

js = '''
    ()=>{
        const newProto = navigator.__proto__;
        delete newProto.webdriver;
        navigator.__proto__ = newProto;
    }
'''
await page.evaluateOnNewDocument(js)

 

上一篇:JS-Web-API-BOM


下一篇:BOM