mirror of
https://github.com/vladocar/screenshoteer.git
synced 2024-11-16 17:08:33 +01:00
Merge pull request #14 from malitov/basic-http-authentication
Added basic HTTP authentication
This commit is contained in:
commit
c82034ddcc
2 changed files with 8 additions and 0 deletions
|
@ -30,6 +30,7 @@ Parameters:
|
||||||
--h - height of the Web Page in px
|
--h - height of the Web Page in px
|
||||||
--waitfor - wait time for the page load in milliseconds
|
--waitfor - wait time for the page load in milliseconds
|
||||||
--el - css selector document.querySelector
|
--el - css selector document.querySelector
|
||||||
|
--auth - basic http authentication
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
@ -52,6 +53,8 @@ screenshoteer --url https://lobste.rs --w 500
|
||||||
|
|
||||||
screenshoteer --url https://news.ycombinator.com/item?id=18598672 --el ".fatitem"
|
screenshoteer --url https://news.ycombinator.com/item?id=18598672 --el ".fatitem"
|
||||||
|
|
||||||
|
screenshoteer --url https:/site.com --auth username;password
|
||||||
|
|
||||||
```
|
```
|
||||||
<p> List of of supported mobile devices: https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js
|
<p> List of of supported mobile devices: https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js
|
||||||
</p>
|
</p>
|
||||||
|
|
5
index.js
5
index.js
|
@ -15,6 +15,7 @@ program
|
||||||
.option('--h, [h]', 'height')
|
.option('--h, [h]', 'height')
|
||||||
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
|
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
|
||||||
.option('--el, [el]', 'element css selector')
|
.option('--el, [el]', 'element css selector')
|
||||||
|
.option('--auth, [auth]', 'Basic HTTP authentication')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (program.url) urlvalue = program.url
|
if (program.url) urlvalue = program.url
|
||||||
|
@ -40,6 +41,10 @@ console.log(fullPage);
|
||||||
const timestamp = new Date().getTime()
|
const timestamp = new Date().getTime()
|
||||||
if (program.w && program.h) await page.setViewport({width: Number(program.w), height: Number(program.h)})
|
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]);
|
||||||
|
if (program.auth) {
|
||||||
|
const [username, password] = program.auth.split(';');
|
||||||
|
await page.authenticate({username:username, password:password});
|
||||||
|
}
|
||||||
await page.goto(urlvalue)
|
await page.goto(urlvalue)
|
||||||
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-')
|
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-')
|
||||||
if (program.waitfor) await page.waitFor(Number(program.waitfor))
|
if (program.waitfor) await page.waitFor(Number(program.waitfor))
|
||||||
|
|
Loading…
Reference in a new issue