Rvest: why does the following xpath returns empty list

情到浓时终转凉″ 提交于 2019-12-13 10:22:17

问题


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

I use the following codes:

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

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


回答1:


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



来源:https://stackoverflow.com/questions/36639127/rvest-why-does-the-following-xpath-returns-empty-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!