Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Puppeteer Test
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
You can’t perform that action at this time.