最新解决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)

 

posted @ 2020-05-12 21:47  贱书生  阅读(3238)  评论(2编辑  收藏  举报