I am experimenting with rvest
to learn web scraping with R. I am trying to replicate the Lego example for a couple of other sections of the page and using selector gadget
to id.
I pulled the example from R Studio tutorial. With the code below, 1 and 2 work, but 3 does not.
library(rvest)
lego_movie <- html("http://www.imdb.com/title/tt1490017/")
# 1 - Get rating
lego_movie %>%
html_node("strong span") %>%
html_text() %>%
as.numeric()
# 2 - Grab actor names
lego_movie %>%
html_nodes("#titleCast .itemprop span") %>%
html_text()
# 3 - Get Meta Score
lego_movie %>%
html_node(".star-box-details a:nth-child(4)") %>%
html_text() %>%
as.numeric()