Created
August 5, 2020 08:11
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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