使用 cheerio 抓取 table 的第 n 个元素?

Scraping the nth element of a table using cheerio?

我要刮这个table的风柱https://www.bmreports.com/bmrs/?q=generation%2Ffueltype&fbclid=IwAR2p2a84CaJhgzF-YOU4MzOS-cMuZUpeDmLHFkWZU7-NauRHrA1owwdsMog 我可以抓取整个 table,但我不知道如何对其进行排序。理想情况下,我只会刮掉一列。

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);



    }
});

怎么样

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 winds = $('.gen-fuel tbody td:nth-child(8)')
                .map(function () {
                    return $(this).text();
                })
                .get();

            console.log(winds);
        }
    }
);

Cheerio 支持 CSS 选择器,凭借其强大的功能,您可以获得包含 wind

中所有值的数组