import pyppeteer import asyncio async def main(): browser = await pyppeteer.launch(headless=False, userDataDir='./userdata', args=['--disable-infobars']) page = await browser.newPage() await page.setViewport({'width': 1366, 'height': 768}) await page.evaluateOnNewdocument('Object.defineProperty(navigator,"webdriver",{get:()=>undefined})') await page.goto('https://www.baidu.com') await asyncio.sleep(10) if __name__ == '__main__': asyncio.get_event_loop().run_until_complete(main())
import pyppeteer import asyncio async def main(): # 加 userDataDir='./userdata' 即可, 同目录下会生成userdata文件夹, 下次打开就会加载 browser = await pyppeteer.launch(headless=False, userDataDir='./userdata', args=['--disable-infobars']) page = await browser.newPage() await page.setViewport({'width': 1366, 'height': 768}) await page.evaluateOnNewdocument('Object.defineProperty(navigator,"webdriver",{get:()=>undefined})') await page.goto('https://www.baidu.com') await asyncio.sleep(10) if __name__ == '__main__': asyncio.get_event_loop().run_until_complete(main())
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)