title: How to use R (Rcurl/XML packages) to scrape options data from Yahoo?
body: <p>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. </p>
  
  <p>(1) <a href="https://stackoverflow.com/questions/1395528/scraping-html-tables-into-r-data-frames-using-the-xml-package">Scraping html tables into R data frames using the XML package</a></p>
  
  <p>As an example I want to scrape and collect the following options chain 
  <a href="http://finance.yahoo.com/q/op?s=MNTA&amp;m=2011-05" rel="nofollow noreferrer">http://finance.yahoo.com/q/op?s=MNTA&amp;m=2011-05</a></p>
  
  <p>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.</p>
  
  <pre><code>library(RCurl)
  library(XML)
  
  theurl &lt;- "http://finance.yahoo.com/q/op?s=MNTA&amp;m=2011-05"
  webpage &lt;- getURL(theurl)
  webpage &lt;- readLines(tc &lt;- textConnection(webpage)); close(tc)
  
  pagetree &lt;- htmlTreeParse(webpage, error=function(...){}, useInternalNodes = TRUE)
  
  tablehead &lt;- xpathSApply(pagetree, "//*/table[@class='yfnc_datamodoutline1']/tr/th", xmlValue)
  
  results &lt;- xpathSApply(pagetree, "//*/table[@class='wikitable sortable']/tr/td", xmlValue)
  </code></pre>
  
  <p>The last two lines don</p>