Last active
December 15, 2017 01:10
-
-
Save shoken0x/cd340902bf42456a83826c142635ee7d to your computer and use it in GitHub Desktop.
puppeteer sample
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
// Usage | |
// yarn add puppeteer | |
// node puppeteer_sample.js | |
const puppeteer = require('puppeteer'); | |
puppeteer.launch({ | |
headless: false, // フルバージョンのChromeを使用 | |
slowMo: 300 // 何が起こっているかを分かりやすくするため遅延 | |
}).then(async browser => { | |
const page = await browser.newPage(); | |
await page.setViewport({ width: 1200, height: 800 }); // view portの指定 | |
await page.goto('https://www.google.co.jp/'); | |
await page.type('#lst-ib', 'KitchHike, Inc'); | |
await page.click('.lsb'); | |
await page.waitFor(3000); // デモのための遅延 | |
await page.goto('https://kitchhike.com/'); | |
await page.waitFor(1000); | |
await page.goto('https://kitchhike.com/jp/popups'); | |
await page.waitFor(3000); | |
browser.close(); | |
browser.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment