Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50142

html text - no tag for data

$
0
0
I'm trying to pull some data with my code that is based on the "innerText" of a tag. I've been able to do it successfully for many sites but I just ran into a websites source code that doesn't seem to have a tag for the data I need. Any help would be greatly appreciated, thanks!

This is the information I need to be able to pull to my spreadsheet: "FEDERAL COST OF FUNDS INDEX FOR MAY AS OF 06/20/13 IS 0.966%"

Code:

Sub Extract_D4()

'  Federal Cost of Funds Index (Freddie Mac)

    Dim URL As String
    Dim IE As InternetExplorer
    Dim HTMLdoc As HTMLDocument
    Dim BRelements As IHTMLElementCollection
    Dim BRelement As HTMLTableCell
    Dim r As Long

'  Goes to and nagivates web page
   
    URL = "http://ww3.freddiemac.com/ds1/sell/sffrny.nsf/frmDisplayRtIndx?OpenForm"
   
    Set IE = New InternetExplorer
   
    With IE
        .Navigate URL
        .Visible = False
   
        While .Busy Or .ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
   
        Set HTMLdoc = .Document
    End With
   
'  Allows website to catch up and fully load
   
    Application.Wait Now + TimeValue("00:00:01")
     
'  Searches source code for data
'  Imports to "WebData" sheet

    Set BRelements = HTMLdoc.getElementsByTagName("BR")
   
    Worksheets("WebData").Range("L2:L41").ClearContents
   
    r = 0
    For Each BRelement In BRelements
            Range("L2").Offset(r, 0).Value = BRelement.innerText
            r = r + 1
    Next
           
End Sub


Viewing all articles
Browse latest Browse all 50142

Trending Articles