How to set Pyppeteer viewport size (screen size)
Setting the viewport size e.g. in order to obtain a Full HD screenshow in Pyppeteer is as easy as
browser = await launch({
"defaultViewport": {"width": 1920, "height": 1080},
})
Full example
#!/usr/bin/env python3
import asyncio
from pyppeteer import launch
async def main():
browser = await launch({
"defaultViewport": {"width": 1920, "height": 1080},
})
page = await browser.newPage()
await page.goto('https://www.techoverflow.net', {'waitUntil': 'networkidle2'})
# Make screenshot
await page.screenshot({'path': 'screenshot.png'})
# Cleanup
await browser.close()
asyncio.get_event_loop().run_until_complete(main())