Load Libraries

Create empty list to hold data from multiple pages

surverydata <- list()

#Read data from a set of web pages

for (i in 1:8) {
 j = i + 31280169
 namePage <- paste0("https://www.ncbi.nlm.nih.gov/biosample/?term=",j)
 #testPage variable will store all data from the webpage
 #similar to what you see with "Inspect Element"
testPage <- read_html(namePage)

#Since the data we want is in a table, this is a good first step
tableText <- testPage %>% 
  html_node("table") %>%
  html_table()

names(tableText)<-c('Question','Response')
surverydata[[as.character(j)]]<-tableText
}

#Use sapply to pull data from list

responses <- sapply(surverydata, function(x) x[2])
ages <- sapply(responses, function(x) x[9])

#Make a pie chart of the response

#Change ages from chr to num 
ages2 <- as.numeric(gsub(" years", "", ages))
table (ages2)
## ages2
## 50 56 58 59 84 86 88 
##  1  1  1  1  2  1  1
pie(table(ages2), main= "Pie Chart of the Host Age")