fix path when no emulate

This commit is contained in:
ZYSzys 2018-12-06 22:14:16 +08:00
parent 920236282b
commit ce7ebb00e0
1 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@ const puppeteer = require('puppeteer')
const devices = require('puppeteer/DeviceDescriptors')
const program = require('commander')
var urlvalue, emulate = "";
let urlvalue;
program
.option('--url, [url]', 'The url')
@ -40,7 +40,10 @@ console.log(fullPage);
const page = await browser.newPage()
const timestamp = new Date().getTime()
if (program.w && program.h) await page.setViewport({width: Number(program.w), height: Number(program.h)})
if (program.emulate) await page.emulate(devices[program.emulate]);
if (program.emulate)
await page.emulate(devices[program.emulate]);
else
program.emulate = '';
if (program.auth) {
const [username, password] = program.auth.split(';');
await page.authenticate({username:username, password:password});