Write js get 2019 blog Star voting and vote count ranking

Here Insert Picture Description
Gets the number of Voting

// app.js
var request = require('request');
var cheerio = require('cheerio');
request('http://m234140.nofollow.ax.mvote.cn/opage/995e42ed-2335-8c44-310e-d2822ef19ca0.html',function(err,result){
    if(err){
        console.log(err);
    }
    var $ = cheerio.load(result.body);
    console.log($('.votenuminfo').text())
})

Get ranking

// ser.js
var http = require("http"); //http服务
var cheerio = require("cheerio"); //cheerio是nodejs的抓取页面模块,为服务器特别定制的,快速、灵活、实施的jQuery核心实现。适合各种Web爬虫程序。
var url = "http://m234140.nofollow.ax.mvote.cn/action/viewvotewxorderlist.html?voteguid=43ced329-3a4b-0a5d-a13c-f088cf8eafef"; //url网址

http.get(url, function(res) {
    var html = "";
    res.on("data", function(chunk) {
        html += chunk; //字符串拼接
    });
    res.on("end", function() {
        var $ = cheerio.load(html);
        var list = $('.voteorderlist')
        list.find('tr').each(function(item) {
            var t=$(this);
            var ee = t.find('a').attr("href");
            if (ee === '/opage/995e42ed-2335-8c44-310e-d2822ef19ca0.html') {
                console.log(t.index()+'名')
            }
        })
    }).on("error", function(err) { //错误监听
        console.log(err.message)
    })
})

To facilitate the operation, you can write a bat

cmd /k "cd /d E:\csdnplus&&node ser.js"
cmd /k "cd /d E:\csdnplus&&node app.js"
Published 160 original articles · won praise 280 · Views 1.69 million +

Guess you like

Origin blog.csdn.net/qq_39045645/article/details/103929227