Rvest:为什么以下 xpath 返回空列表 [英] Rvest: why does the following xpath returns empty list

查看:65
本文介绍了Rvest:为什么以下 xpath 返回空列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 rvest 从烂番茄中提取标题

I am trying to extract the titles using rvest from rotten tomatoes

我使用以下代码:

urlhtml<-read_html("http://www.rottentomatoes.com/browse/opening/")
df<-html_text(html_nodes(urlhtml,xpath="//*[@id='movies-collection']/div/div/div[2]/a"))

xpath 源自 google chrome,所以我认为它是正确的,但是,它返回空列表......我不知道出了什么问题.

the xpath is derived from google chrome so I believe it's correct, however, it returns empty list... I can't figure out what is wrong.

有人可以帮忙吗?非常感谢

Could anyone help? Much appreciated

推荐答案

谢谢大家,原来就像@RogerLindsjö说的,我需要一个javascript先解析html,用phantomjs配合R报废

Thanks everyone, it turns out like @RogerLindsjö said, I need a javascript to parse the html first and use phantomjs to cooperate R scrapping

这篇关于Rvest:为什么以下 xpath 返回空列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆