问题
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