I want to pull in data from 538, but I want the full data which is arrived at by clicking on "Show more polls"... Is there any way for the function to access the additional lines of the table?
I believe the data for for all 530 polls is not directly in a
in the HTML so you won't find it that way. Instead, that content is dynamically constructed using the data that is contained in a script node. The following is a specific way of doing it that could be generalized if necessary.
I want to pull in data from 538, but I want the full data which is arrived at by clicking on "Show more polls"... Is there any way for the function to access the additional lines of the table?
http://projects.fivethirtyeight.com/2016-election-forecast/national-polls/
The code for pulling in the top level data is:
require(XML) polls.html <- htmlTreeParse("http://projects.fivethirtyeight.com/2016-election-forecast/national-polls/", useInternalNodes = TRUE) parsedDoc <- readHTMLTable(polls.html, stringsAsFactors=FALSE) pollData <- data.frame(parsedDoc[4])