CNode

简易'爬虫',也说不上是不是

分享
Mmiss61008596发布于9 年前最后回复9 年前0 回复2819 浏览0 收藏
const cheerio = require('cheerio');
var fetch = require ('node-fetch');

fetch('http://www.bwlc.net/bulletin/keno.html')
    .then(function(response) {
        return response.text()
    }).then(function(body) {
    const $ = cheerio.load(body);
    let periodNum = $('div .lott_cont table tr td').html();
    console.log(parseInt(periodNum, 10));
    console.log($('div .lott_cont table tr td').next().html());
    console.log($('div .lott_cont table tr td').next().next().html());
    console.log($('div .lott_cont table tr td').next().next().next().html());
}).catch(err => {
    console.log(err);
});
查看回复

回复 (0)

暂无回复,成为第一个参与讨论的人。
参与回复
登录后即可参与回复。登录