Python pyppeteer通过cookie获取数据(cookie爬虫)
生活随笔
收集整理的這篇文章主要介紹了
Python pyppeteer通过cookie获取数据(cookie爬虫)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1. 利用EditThisCookie插件獲取頁面cookie
2. 源碼實(shí)例
"""set browser"""browser = await launch({"headless": False,"executablePath": "F:\\chrome-win32\\chrome.exe","args": ["--disable-gpu","--disable-web-security","--disable-xss-auditor", # 關(guān)閉 XSS Auditor"--no-sandbox","--disable-setuid-sandbox","--allow-running-insecure-content", # 允許不安全內(nèi)容"--disable-webgl",],"ignoreHTTPSErrors": True # 忽略證書錯(cuò)誤})width, height = screen_size()page = await browser.newPage()tasks = [# 設(shè)置UAasyncio.ensure_future(page.setUserAgent(random.choice(user_agents))),# 啟用JS,不開的話無法執(zhí)行JSasyncio.ensure_future(page.setJavaScriptEnabled(True)),# 關(guān)閉緩存asyncio.ensure_future(page.setCacheEnabled(False)),# 設(shè)置窗口大小asyncio.ensure_future(page.setViewport({"width": width, "height": height}))]await asyncio.wait(tasks)cookies = [{},{}]for item in cookies:await page.setCookie(item)"""Search"""url = "https://www.abc.cn"await page.goto(url, {"waitUntil": "networkidle2", "timeout": 30000})?
總結(jié)
以上是生活随笔為你收集整理的Python pyppeteer通过cookie获取数据(cookie爬虫)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2018.09.01 独立集(树形dp)
- 下一篇: Python函数传入的参数是否改变(函数