Rvest: why does the following xpath returns empty

2019-09-20 10:18发布

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条回答
该账号已被封号
2楼-- · 2019-09-20 11:17

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

查看更多
登录 后发表回答