Skip to content

Commit

Permalink
adds dotenv and logs in
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Alfaro committed Oct 9, 2018
1 parent 6a7d8b2 commit ed362a1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
HT_USER=your_user
HT_PASS=your_password
SITE_URL=https://google.com
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
require('dotenv').config()
const puppeteer = require('puppeteer');

(async() => {
const browser = await puppeteer.launch();
console.log(await browser.version());
const page = await browser.newPage();
try {
await page.authenticate({username:process.env.HT_USER, password:process.env.HT_PASS});
await page.goto(process.env.SITE_URL, {waitUntil: 'networkidle2'});
await page.pdf({path: 'page.pdf', format: 'A4'});
await browser.close();
}
catch (e){
console.error(e);
}
})();
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"homepage": "https://github.com/rafalfaro18/headless-chrome-puppeteer-broken-images#readme",
"dependencies": {
"dotenv": "^6.1.0",
"puppeteer": "^1.9.0"
}
}

0 comments on commit ed362a1

Please sign in to comment.