我想刮这张桌子的风柱https://www.bmreports.com/bmrs/?q=generation%2Ffueltype&fbclid=IwAR2p2a84CaJhgzF-YOU4MzOS-cMuZUpeDmLHFkWZU7-NauRHrA1owwdsMog 我可以刮整个桌子,但我不知道怎么做对其进行排序。理想情况下,我只会刮掉一列。
const request = require('request');
const cheerio = require('cheerio');
request('https://www.bmreports.com/bmrs/?q=generation%2Ffueltype&fbclid=IwAR2p2a84CaJhgzF-YOU4MzOS-cMuZUpeDmLHFkWZU7-NauRHrA1owwdsMog', (error, response, html) =>
{
if (!error && response.statusCode == 200)
{
const $ = cheerio.load(html);
const table = $('.gen-fuel');
var newArray = [];
var windArray = [];
// console.log(table.html());
$('td').each((i, el) =>
{
const item = $(el).html();
newArray.push(item);
console.log(item)
});
const every7thValue = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
console.log(every7thValue(newArray, 7));
//console.log(newArray);
}
});
喵喵时光机
相关分类