Open miaohancheng opened 5 years ago
here are the docs for that option
https://miyakogi.github.io/pyppeteer/_modules/pyppeteer/page.html#Page.emulate
which can essentially be called (based on the source code above)
This method is a shortcut for calling two methods:
* :meth:`setUserAgent`
* :meth:`setViewport`
so, you can set them individually via
https://miyakogi.github.io/pyppeteer/reference.html#pyppeteer.page.Page.setViewport https://miyakogi.github.io/pyppeteer/reference.html#pyppeteer.page.Page.setUserAgent
sample setviewport code
await page.setViewport({"width": 860, "height": 1000})
Edit: See puppeteer docs for available devices (copy json values and send them to setviewport and setuseragent(optional)) https://github.com/GoogleChrome/puppeteer/blob/master/lib/DeviceDescriptors.js
This is the js code, But i cant find the device class in pyppeteer. Maybe someone can help me , thanks
`const puppeteer = require('puppeteer'); const iPhone = puppeteer.devices['iPhone 6'];
puppeteer.launch().then(async browser => { const page = await browser.newPage(); await page.emulate(iPhone); await page.goto('https://www.google.com'); // other actions... await browser.close(); });`