Install pyppeteer in Python

  • pip install pyppeteer

  • pyppeteer-install to download latest Chrome version into ~/.local/share/pyppeteer.

  • Put following codes into a script and run it.

import asyncio
from pyppeteer import launch

async def main():
    browser = await launch()
    page = await browser.newPage()
    await page.goto('http://example.com')
    await page.screenshot({'path': 'example.png'})
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())

It will throw missing library error anyway.

  • Use ldd ~/.local/share/pyppeteer/.../chrome to check what libs are missing. Install missing libs in system.

  • Rerun the script.


Published

Category

Python

Tags

Contact