Skip to content

Instantly share code, notes, and snippets.

@Jonty
Created December 8, 2017 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonty/64501bb885a6f44f6f3f3a274b7a0ac8 to your computer and use it in GitHub Desktop.
Save Jonty/64501bb885a6f44f6f3f3a274b7a0ac8 to your computer and use it in GitHub Desktop.
import asyncio
from pyppeteer.launcher import launch
async def to_pdf(browser, url):
page = await browser.newPage()
await page.goto(url)
pdf = await page.pdf()
with open('emfcamp.pdf', 'wb') as f:
f.write(pdf)
url = "http://emfcamp.org"
browser = launch()
asyncio.get_event_loop().run_until_complete(to_pdf(browser, url))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment