美文网首页
playwright隐藏特征

playwright隐藏特征

作者: 山猪打不过家猪 | 来源:发表于2022-09-01 15:53 被阅读0次

方法一:

from playwright.sync_api import Playwright, sync_playwright

playwright = sync_playwright().start()
browser = playwright.chromium.launch(headless=False)

context = browser.new_context()
page = context.new_page()
# # 关闭Webdriver属性
js = """
        Object.defineProperties(navigator, {webdriver:{get:()=>undefined}});
        """
page.add_init_script(js)

方法二:

context.add_init_script("Object.defineProperties(navigator, {webdriver:{get:()=>false}});")

context.add_init_script("const newProto = navigator.__proto__; delete newProto.webdriver; navigator.__proto__ = newProto;")

相关文章

网友评论

      本文标题:playwright隐藏特征

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