1.selenium 处理方法
from selenium import webdriver
from selenium.webdriver import ChromeOptions
def get_cookie():
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
driver = webdriver.Chrome(executable_path="./chromedriver", options=option)
driver.get('http://wenshu.court.gov.cn')
cookie = driver.get_cookies()
print(cookie)
get_cookie()
2. pyppeteer 处理方法
import asyncio
from pyppeteer import launch
from pyppeteer import launcher
from pyquery import PyQuery as pq
launcher.AUTOMATION_ARGS.remove("--enable-automation")
async def main():
browser = await launch(headless=False)
page = await browser.newPage()
await page.goto('http://wenshu.court.gov.cn/')
doc = pq(await page.content())
print('Quotes:', doc('.quote').length)
asyncio.get_event_loop().run_until_complete(main())