获取投票数
// 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()) })
获取名次
// 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 = KaTeX parse error: Expected '}', got 'EOF' at end of input: … var t=(this); var ee = t.find(‘a’).attr(“href”); if (ee === ‘/opage/995e42ed-2335-8c44-310e-d2822ef19ca0.html’) { console.log(t.index() 1 ‘名’) } }) }).on(“error”, function(err) { //错误监听 console.log(err.message) }) })
更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/119816146