Basically, I want to scrape some options data daily from Yahoo! Finance. I have been kicking the tires using (1) as an example. However it hasn't quite worked out, since I am unfamiliar with HTML.
(1) Scraping html tables into R data frames using the XML package
As an example I want to scrape and collect the following options chain http://finance.yahoo.com/q/op?s=MNTA&m=2011-05
Here is what I have tried so far. The last 2 lines don't work since I am unclear what class I should be looking for. Any help would be great. Thanks.
library(RCurl)
library(XML)
theurl <- "http://finance.yahoo.com/q/op?s=MNTA&m=2011-05"
webpage <- getURL(theurl)
webpage <- readLines(tc <- textConnection(webpage)); close(tc)
pagetree <- htmlTreeParse(webpage, error=function(...){}, useInternalNodes = TRUE)
tablehead <- xpathSApply(pagetree, "//*/table[@class='yfnc_datamodoutline1']/tr/th", xmlValue)
results <- xpathSApply(pagetree, "//*/table[@class='wikitable sortable']/tr/td", xmlValue)
The last two lines don