HI
I found a very useful piece of code which allows you to extract information from websites and return it into your spreadsheet as long as you know the element ID of the field from the HTML document. The code below works on the yahoo finance website where at the moment it navigates to Vodafone stock and returns a price by using HTMLDoc.getElementById("yfs_l10_" &stocksymol).innerText method.
I would like to modify the code to extract info from other websites however i don't know how to find my element ID which i would put in place of "yfs_l10_".
Could anyone drop me a snippet or a link which would show how to get a list of all the elemements and their ID's for a particular website?
many thanks
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub mainMacro()
showWebsite "
End Sub
Sub showWebsite(ByVal URL As String)
Dim IEApp As InternetExplorer 'Need a reference to Microsoft Internet Controls
Dim HTMLDoc As HTMLDocument 'Need a reference to Microsoft HTML Object Library
Set IEApp = New InternetExplorer
IEApp.Visible = True
IEApp.Navigate URL
Do
DoEvents
Loop Until IEApp.ReadyState = READYSTATE_COMPLETE
Set HTMLDoc = IEApp.Document
getYahooStockQuote HTMLDoc, "vod"
IEApp.Quit
Set IEApp = Nothing
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''
Sub getYahooStockQuote(HTMLDoc As HTMLDocument, StockSymbol As String)
Debug.Print HTMLDoc.getElementById("yfs_l10_" & StockSymbol).innerText
End Sub
I found a very useful piece of code which allows you to extract information from websites and return it into your spreadsheet as long as you know the element ID of the field from the HTML document. The code below works on the yahoo finance website where at the moment it navigates to Vodafone stock and returns a price by using HTMLDoc.getElementById("yfs_l10_" &stocksymol).innerText method.
I would like to modify the code to extract info from other websites however i don't know how to find my element ID which i would put in place of "yfs_l10_".
Could anyone drop me a snippet or a link which would show how to get a list of all the elemements and their ID's for a particular website?
many thanks
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub mainMacro()
showWebsite "
End Sub
Sub showWebsite(ByVal URL As String)
Dim IEApp As InternetExplorer 'Need a reference to Microsoft Internet Controls
Dim HTMLDoc As HTMLDocument 'Need a reference to Microsoft HTML Object Library
Set IEApp = New InternetExplorer
IEApp.Visible = True
IEApp.Navigate URL
Do
DoEvents
Loop Until IEApp.ReadyState = READYSTATE_COMPLETE
Set HTMLDoc = IEApp.Document
getYahooStockQuote HTMLDoc, "vod"
IEApp.Quit
Set IEApp = Nothing
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''
Sub getYahooStockQuote(HTMLDoc As HTMLDocument, StockSymbol As String)
Debug.Print HTMLDoc.getElementById("yfs_l10_" & StockSymbol).innerText
End Sub