我正在抓取网页https://www.g2a.com/rising-storm-2-vietnam-steam-cd-key-global.html
我需要从表数据中获取标题。
var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
app.get('/scrape', function(req, res) {
url = 'https://www.g2a.com/rising-storm-2-vietnam-steam-cd-key-global.html';
request(url, function(error, response, body) {
if (!error) {
var $ = cheerio.load(body);
var arr = [];
var title = $('.mp-user-rating tr td').each(function(element) {
var tableData = $(element).find('.mp-rating-popup');
arr.push({ 'title': tableData.text() });
});
console.log(arr);
}
res.send(arr);
});
})
app.listen('8081');
console.log('Magic happens on port 8081');
exports = module.exports = app;这里arr总是空的。

该图像显示了表的结构
任何帮助都将不胜感激。
https://stackoverflow.com/questions/44659315
复制相似问题