您如何使用rvest刮擦标题和视图数量
我想在不使用YouTube API的情况下在YouTube上刮擦信息。我尝试使用以下代码使用XPATH,但它返回字符(空)。
html <- read_html("https://www.youtube.com/watch?v=WRz2MxhAdJo")
title <- html_nodes(html,xpath = '//*[@id="container"]/h1') %>% html_text()
I want to scrape information on Youtube without using YouTube api. I tried using the code below using xpath but it returns character(empty).
html <- read_html("https://www.youtube.com/watch?v=WRz2MxhAdJo")
title <- html_nodes(html,xpath = '//*[@id="container"]/h1') %>% html_text()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从网页上从
meta
标签中提取标题和视图。标题在
&lt; meta name =“ title”
标签中。示例:
视图(称为互动)在
&lt; meta itemprop =“ InteractionCount”
tag中。示例:
为此,您可以使用
You can extract the title and views from the
meta
tags from the webpage.The title is in the
<meta name="title"
tag.Example:
The views (called interaction) is in the
<meta itemprop="interactionCount"
tag.Example:
For this, you can use something like shown in this answer: