Skip to content

Instantly share code, notes, and snippets.

@blackstuend
Last active March 27, 2019 01:48
Show Gist options
  • Save blackstuend/66f3f98abda65be16153b1e46bb18d5e to your computer and use it in GitHub Desktop.
Save blackstuend/66f3f98abda65be16153b1e46bb18d5e to your computer and use it in GitHub Desktop.

Puppteer

Install

# npm i puppeteer

Use

const puppeteer = require('puppeteer');
(async() =>{
const brower = awiat puppeteer.launch()
//const browser = await puppeteer.launch({
    headless: false
});  //headless = false 顯示出瀏覽器
})
const page = await brower.newpage();
await page.goto('http://select.nqu.edu.tw/kmkuas/index_sky.html'); //前往網址
var body = await page.evaluate(()=>document.body.innerHTML) //傳出body

常用

page.click() 
const menu = (await page.frames())[2]; //如果網頁有frameset 使用這個獲取其他的frame,aspnet使用的
page.waitFor(500) //等待0.5 毫秒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment