Web scraping 在抓取网站时,$()在浏览器控制台中提供数据,但在节点js中它抛出未定义的数据
Web scraping 在抓取网站时,$()在浏览器控制台中提供数据,但在节点js中它抛出未定义的数据,web-scraping,cheerio,Web Scraping,Cheerio,$('div[class=“*someclassname*”]>p')在浏览器控制台中工作正常,但在node js中,此结果未定义,请提供帮助 const axios = require('axios'); const cheerio = require('cheerio'); const url = 'somewebsite'; axios(url) .then(response => { const html = response.data;
$('div[class=“*someclassname*”]>p')
在浏览器控制台中工作正常,但在node js中,此结果未定义,请提供帮助
const axios = require('axios');
const cheerio = require('cheerio');
const url = 'somewebsite';
axios(url)
.then(response => {
const html = response.data;
const $ = cheerio.load(html);
const statsTable = $('div[class="*someclassname*"] > P');// this results correct data in browser
console.log(statsTable.textContent);
console.log(statsTable.text());
})
.catch(console.error);