Results 1 to 3 of 3

getElementsByTagName - extract HTML from website

Threaded View

  1. #1
    Registered User
    Join Date
    02-19-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2013
    Posts
    33

    getElementsByTagName - extract HTML from website

    Hi Forum,

    I am new to Excel VBA (and this forum, please forgive any shortcomings) and I am trying to use Excel VBA 2010 to scrape some prices (2.40) from a horse racing website. This is the HTML I am trying to scrape:

    <span id="price-box-str_56891231_L_W" class="price_box_str">
    2.40
    </span>
    http://www.sportsbet.com.au/horse-ra...-1-585168.html

    Here is the macro I am trying to use to scrape it:

    Sub SportsBetScraper()
    
    ' SportsBetScraper Macro
    
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate Range("E4")
    
    Do
    DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    
    Dim Doc As HTMLDocument
    Set Doc = IE.document
    
    Dim PriceData As String
    PriceData = Trim(Doc.getElementsByTagName("price-box-str_56891231_L_W")(0).innerText)
    MsgBox PriceData
    
    End Sub
    I copied most of this macro from a YouTube video. Everything works except the parameter "price-box-str_56891231_L_W". I know this because when I use "body" instead, the correct information is returned. Could someone help me get this macro working?

    Cheers, Rob
    Last edited by killerkoz17; 02-19-2013 at 07:07 PM. Reason: better title

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1