Fixed line endings

This commit is contained in:
Uwe Oestermeier 2019-06-06 16:17:58 +02:00
parent 502bdf47a3
commit 6f7a18d6b8
1 changed files with 13 additions and 13 deletions

View File

@ -1,9 +1,9 @@
/** /**
* *
* make screenshots and log errors to * make screenshots and log errors to
* console * console
* (c) 2019 - Leibniz-Insitut für Wissensmedien * (c) 2019 - Leibniz-Insitut für Wissensmedien
* *
*/ */
const puppeteer = require('puppeteer'); const puppeteer = require('puppeteer');
@ -24,13 +24,13 @@ function logPageEvent(event){
} }
async function makeScreenshot(href){ async function makeScreenshot(href){
const browser = await puppeteer.launch({args: [ const browser = await puppeteer.launch({args: [
'allow-file-access-from-files', 'allow-file-access-from-files',
],}); ],});
const page = await browser.newPage(); const page = await browser.newPage();
await page.setViewport({width: 1024,height : 624}) await page.setViewport({width: 1024,height : 624})
// register events // register events
@ -53,9 +53,9 @@ async function makeScreenshot(href){
} }
// image_url = image_url.replace("file:///","") // image_url = image_url.replace("file:///","")
// fpath = fpath.replace("file:///","") // fpath = fpath.replace("file:///","")
page.removeAllListeners() page.removeAllListeners()
fs.ensureDir(fpath) fs.ensureDir(fpath)
await page.screenshot({path: image_url}); await page.screenshot({path: image_url});
@ -63,10 +63,10 @@ async function makeScreenshot(href){
} }
/** /**
* *
* collect all navigational links in all documents * collect all navigational links in all documents
* *
* */ * */
async function collectLinks(href,reflist) async function collectLinks(href,reflist)
{ {
@ -76,12 +76,12 @@ async function collectLinks(href,reflist)
await page.goto(href) await page.goto(href)
let hrefs = await page.$$('a.wrapper') let hrefs = await page.$$('a.wrapper')
for (var i=0; i < hrefs.length; i++) { for (var i=0; i < hrefs.length; i++) {
let hrefValue = await hrefs[i].getProperty('href') let hrefValue = await hrefs[i].getProperty('href')
let linkText = await hrefValue.jsonValue(); let linkText = await hrefValue.jsonValue();
if (!linkText.startsWith("file:")) if (!linkText.startsWith("file:"))
{ {
continue; continue;
} }
if(linkText.endsWith("#")) continue; if(linkText.endsWith("#")) continue;
@ -113,4 +113,4 @@ async function collectLinks(href,reflist)
await makeScreenshot(reflist[i]) await makeScreenshot(reflist[i])
console.log(i,reflist[i]) console.log(i,reflist[i])
} }
})() })()