Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4551226
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:36:22+00:00 2026-05-21T16:36:22+00:00

Basically, I want to scrape some options data daily from Yahoo! Finance. I have

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:36:23+00:00Added an answer on May 21, 2026 at 4:36 pm

    I presume that you want to get the information in the two tables Call Options and Put Options. Here is one simple way to do it using the XML package

    url  = "http://finance.yahoo.com/q/op?s=MNTA&m=2011-05"
    # extract all tables on the page
    tabs = readHTMLTable(url, stringsAsFactors = F)
    
    # locate tables containing call and put information
    call_tab = tabs[[11]]
    put_tab  = tabs[[15]]
    

    I figured out the position of the two tables by manual inspection. If the position is going to vary across the pages you are parsing, then you might want to programatically define the position, either using length of table or some other text criteria.

    EDIT. The two tables you are presumably interested in both have cellpadding = 3. You can use this information to directly extract the two tables using the following code

    # parse url into html tree
    doc = htmlTreeParse(url, useInternalNodes = T)
    
    # find all table nodes with attribute cellpadding = 3
    tab_nodes = xpathApply(doc, "//table[@cellpadding = '3']")
    
    # parse the two nodes into tables
    tabs = lapply(tab_nodes, readHTMLTable)
    names(tabs) = c("calls", "puts")
    

    This is a list that contains both tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically want to open a browser window from Word using VBA that does
Basically, I have a block of memory allocated using malloc that I want to
I have a relatively simple case. I basically want to store data about links
I'm using Simple HTML DOM to scrape (with permission) some websites. I basically scrape
basically, I am trying to scrape webpages with php but I want to do
I have a similar question to this: PHP session timeout callback? Basically, I want
Basically I need to scrape some text that has nested tags. Something like this:
I have a library with a class that, when created, will automatically scrape data
I basically want to achieve what a RadioButtonList does, without using that control (i.e.
I basically want to dynamically apply some style to all elements in a page,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.