Created
September 14, 2022 17:25
-
-
Save jack828/4bc3c2296a478f3c771ec7f40add4457 to your computer and use it in GitHub Desktop.
HM Hospitales WiFi Auto Submit
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
#!/usr/bin/env node | |
const puppeteer = require('puppeteer') | |
;(async () => { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
args: ['--ignore-certificate-errors', '--disable-web-security'] | |
}) | |
const page = await browser.newPage() | |
await page.goto(`http://example.com/?${Date.now()}`, { | |
waitUntil: ['domcontentloaded', 'networkidle0'] | |
}) | |
await page.waitForSelector('input[type=email]') | |
console.log('Portal loaded') | |
await page.type('input[type=email]', '[email protected]') | |
await page.evaluate(() => { | |
document.querySelector('input[type=checkbox]').click() | |
}) | |
await page.click('input[type=submit]') | |
await page.waitForNavigation({ waitUntil: 'networkidle0' }) | |
console.log('Got code page') | |
await page.click('input[type=submit]') | |
await page.waitForNavigation({ waitUntil: 'networkidle0' }) | |
await page.waitForSelector('#proceed-button') | |
console.log('Submitted form') | |
await page.click('#proceed-button') | |
await page.waitForNavigation({ waitUntil: 'networkidle0' }) | |
console.log('done') | |
await page.close() | |
await browser.close() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment