My main goal with cheerio is to scrape the titles from this IMDb ranking:
Despite following the documentation and specifying the exact HTML path for the titles, I am getting back random and confusing objects like:
'x-attribsNamespace': [Object: null prototype] {},
'x-attribsPrefix': [Object: null prototype] {}
},
'80': <ref *81> Element {
parent: Element {
...
Code:
import * as cheerio from 'cheerio';
import axios from 'axios';
import fs from 'fs';
axios("https://www.imdb.com/chart/tvmeter/?ref_=nv_tvv_mptv").then(res => {
const data = res.data;
const $ = cheerio.load(data);
var cheerioData = $('.lister-list>tr').each((i, e) => {
const title = $(e).find('.titleColumn a').text();
console.log(title);
})
console.log(cheerioData);
})
I'm struggling to figure out what's going wrong since the path seems to be correct. Can anyone offer some help?