Skip to content

Instantly share code, notes, and snippets.

@harryWonder
Created August 5, 2020 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryWonder/768ff46b377bcc20dcf18abb4b954960 to your computer and use it in GitHub Desktop.
Save harryWonder/768ff46b377bcc20dcf18abb4b954960 to your computer and use it in GitHub Desktop.
This file logins in a user and generates a Png screenshot of the dashboard page to show the login process.
/**
* @author Ilori Stephen A
* @desc This is a simple web scraper in js that scrapes website, generates a json response and save it to file, generates a pdf and a screenshot of the operation.
**/
const Puppeteer = require('puppeteer');
class AuthenticationScraper {
async login() {
const Browser = await Puppeteer.launch({
headless: false,
});
const Page = await Browser.newPage();
await Page.goto('https://www.codelighters.com/login');
await Page.type("#email", "YOUR-EMAIL-ADDRESS");
await Page.type("#password", "YOUR-CODELIGHTERS-PASSWORD");
await Promise.all([
Page.click('.btn-primary'),
]);
await Page.waitForNavigation({ waitUntil: 'networkidle0' })
await Page.screenshot({
path: './public/img/' + new Date().toISOString() + '.png',
fullPage: true
});
await Browser.close();
}
}
module.exports = new AuthenticationScraper();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment