【发布时间】:2019-11-20 19:48:19
【问题描述】:
我对使用任何 API 既不感兴趣,也不对 request-promie 和 Cheerio 以外的任何其他库感兴趣。当我输入指向 yt 频道页面的链接时,我正在尝试获取 yt 频道的名称。文本位于唯一标签内,格式如下:<yt-formatted-string id="text" class="style-scope ytd-channel-name">NAME OF CHANNEL</yt-formatted-string> 我尝试了以下方法
$('yt-formatted-string', html).text()
$('.ytd-channel-name', html).text()
$('div > yt-formatted-string', html).text()
还有一些其他的组合,但似乎 Cheerio 库无法识别自定义制作的标签,例如“yt-formatted-string”以及它们的属性!关于如何克服这个问题的任何建议?
【问题讨论】:
标签: node.js web-crawler cheerio