Created
December 8, 2018 10:15
-
-
Save huyinjie/bd1733be239ed69352acd7aa33b05dfa to your computer and use it in GitHub Desktop.
Puppeteer Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({ | |
headless : true | |
}); | |
const page = await browser.newPage(); | |
await page.setExtraHTTPHeaders({ | |
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', | |
'Accept-Encoding':'gzip, deflate', | |
'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8', | |
'Cache-Control':'no-cache', | |
'Connection':'keep-alive', | |
'Host':'www.dianping.com', | |
'Pragma':'no-cache', | |
'Upgrade-Insecure-Requests':'1', | |
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' | |
}); | |
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'); | |
// 请在此添加Cookie | |
await page.setCookie('') | |
await page.goto( | |
'http://www.dianping.com/shop/103638985', | |
{"waitUntil" : "networkidle0"} | |
); | |
await page.waitFor(6000); | |
await page.screenshot({ | |
path: 'example2.png', | |
fullPage: true | |
}); | |
// await browser.close(); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment