写个js获取2019博客之星投票活动的名次与投票数
获取投票数
// 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?