For my first exercise in webscraping in R, I am trying to figure out how to search through opera tickets being sold to eventually find the best deal. I would like to do two things:
- Create a table of categories and prices to be able to search the best price in any category
- Save a link to the http address of the best deal (price per category).
Based on other posts found on the forum, I can create a fairly messy table, but the table only contains 15 tickets -- it is not the full table I'm looking for. Here is the (relatively simple) code so far:
library(XML)
url <-"http://ift.tt/1KZ2vqR"
operas <- readHTMLTable(url)
n.rows <- unlist(lapply(operas, function(t) dim(t)[1]))
out <-as.data.frame(operas[[which.max(n.rows)]])
colnames(out) <-c("Date","Cat","Price","Links","Number") #add row names
No comments:
Post a Comment