forked from TruthHun/BookStack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crawl.js
26 lines (25 loc) · 784 Bytes
/
crawl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
// const browser = await puppeteer.launch();
const page = await browser.newPage();
let args = process.argv.splice(2);
let url,timeout;
let l=args.length;
for(var i=0;i<l;i++){
switch (args[i]){
case "--url":
url = args[i+1];
if (url==undefined){
url = "";
}
break;
}
i++;
}
page.setExtraHTTPHeaders({"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,co;q=0.7,fr;q=0.6,zh-HK;q=0.5,zh-TW;q=0.4"})
await page.goto(url, {waitUntil: 'networkidle2'});
let content=await page.content();
console.log(content);
browser.close();
})();