爬取地图列表并下载-node.js
var fs = require('fs'); var request = require('request'); var cheerio = require('cheerio'); var url = 'https://github.com/ecomfe/echarts/tree/master/map/js/province/' try{ request(url,(error,response,data)=>{ $ = cheerio.load(data); let arr = []; for(let i=0;i<$('div.file-wrap td.content a.js-navigation-open').length;i++){ let file = $('div.file-wrap td.content a.js-navigation-open')[i].attribs.title; request(`http://echarts.baidu.com/examples/vendors/echarts/map/js/province/${file}?_v_=1519819816100`).pipe(fs.createWriteStream(`./map/${file}`)) } }) }catch(error){ console.log(error) }