puppeteer获取课程并写入json
const puppeteer = require ( 'puppeteer' ) ; const fs = require ( 'fs' ) ; const imoocUrl = 'https://www.imooc.com/course/list?c=fe' ; ; ( async ( ) => { const browser = await puppeteer . launch ( { headless : false , defaultViewport : { width : 1920 , height : 1080 } } ) ; const page = await browser . newPage ( ) ; console . log ( 'start open url:' , imoocUrl ) ; await page . goto ( imoocUrl ) ; //操作数据 console . log ( 'operate dom by console' ) ; const result = await page . evaluate ( ( ) => { let $ = window . $ ; let data = [ ] ; let courseList = $ ( '.moco-course-list' ) . find ( '.course