Last active
January 8, 2018 09:58
-
-
Save mkamakura/fb7ee997d4b1680a2ddefb36c8116222 to your computer and use it in GitHub Desktop.
working holiday canada
This file contains hidden or 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
// yarn init | |
// yarn add puppeteer | |
// node check.js | |
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch() | |
const page = await browser.newPage() | |
await page.goto('http://www.cic.gc.ca/english/work/iec/selections.asp', { waitUntil: 'networkidle2' }) | |
await page.mainFrame().select('select#country-name', 'jp') | |
await page.mainFrame().select('select#category-name', 'wh') | |
await page.click('#submit') | |
await page.waitFor(1000) | |
const rect = await page.evaluate(() => { | |
const rect = document.querySelector('#stats').getBoundingClientRect() | |
return { | |
x: rect.left, | |
y: rect.top, | |
width: rect.width, | |
height: rect.height + 50 | |
} | |
}) | |
await page.screenshot({ path: 'screenshot.png', clip: { ...rect } }) | |
await browser.close() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment