如何在 Puppeteer 中禁用图像/CSS?
我看过这个教程 https://www.scrapehero.com/how-to-increase-web-scraping-speed-using-puppeteer/
但我不知道如何将其翻译成 Python
最佳答案
基于来自 https://github.com/miyakogi/pyppeteer/blob/dev/pyppeteer/page.py#L312 的示例:
await page.setRequestInterception(True)
async def intercept(request):
if any(request.resourceType == _ for _ in ('stylesheet', 'image', 'font')):
await request.abort()
else:
await request.continue_()
page.on('request', lambda req: asyncio.ensure_future(intercept(req)))
关于python-3.x - 如何在 Pyppeteer 中禁用图像/CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59471331/