【发布时间】:2020-12-08 02:20:39
【问题描述】:
我正在 William Hill 网站上使用 node 和cheerio 练习一些网络抓取,但是当我到达代码中的某个点时,它几乎停止了,尽管 div 充满了 html 和 inspect 元素显示了这一点,并且调用 .html() 时,它只返回 ,就好像它是空的一样。此 div 中的任何元素定位都返回 null。
request('https://sports.williamhill.com/betting/en-gb/football/competitions/OB_TY295/English-Premier-League/matches/OB_MGMB/Match-Betting', (error, response, html) => {
if(!error && response.statusCode == 200){
const $ = cheerio.load(html)
const bet = $('#football div[data-test-id="events-group"]')
console.log(bet.html())
}
})
我对网络抓取完全陌生,所以我希望这是有道理的,如果可能的话,请尽量“简化”你的答案。谢谢
【问题讨论】:
标签: node.js web-scraping cheerio