python: 用pyppeteer以无头方式抓取页面
一,安装第三方库:
$ pip install pyppeteer
$ pip install beautifulsoup4
二,代码
import asyncio
from pyppeteer import launch
async def check():
browser = await launch(executablePath='/usr/bin/google-chrome-stable')
page = await browser.newPage()
await page.goto('https://example.com')
print(await page.title())
await browser.close()
asyncio.run(check()) # 应输出"Example Domain"
浙公网安备 33010602011771号