Hi All!
I am trying to come up with some code that will 'scrape' a couple of values from a website and save those values into a couple of Excel cells, and possibly autoupdate those cells whenever the website updates those values that were scraped.
The site that I am trying to scrape from is https://www.poloniex.com/exchange#btc_dgb
I am trying to Capture the top value listed for 'price' under the "SELL ORDERS", and the top value listed for 'price' under the "BUY ORDERS", which are located about half way down the page.
The problem that I am encountering is that, as the list of 'buy' and 'sell' orders change, the code to capture the values that I seek also change.
Sample code:
Any help from the members here would be most greatly appreciated!
I am trying to come up with some code that will 'scrape' a couple of values from a website and save those values into a couple of Excel cells, and possibly autoupdate those cells whenever the website updates those values that were scraped.
The site that I am trying to scrape from is https://www.poloniex.com/exchange#btc_dgb
I am trying to Capture the top value listed for 'price' under the "SELL ORDERS", and the top value listed for 'price' under the "BUY ORDERS", which are located about half way down the page.
The problem that I am encountering is that, as the list of 'buy' and 'sell' orders change, the code to capture the values that I seek also change.
Sample code:
Code:
'
Dim IE As New InternetExplorer
Dim element As Object
'
' Allow the Browser window, that we will be scraping values from, to be visible
IE.Visible = True
'
Application.StatusBar = "Loading website … https://www.poloniex.com/exchange#btc_dgb" ' Update status bar to inform the user of what is occurring
'
' Browser address that we will be scraping values from
IE.navigate "https://www.poloniex.com/exchange#btc_dgb"
'
Do While (IE.Busy Or IE.readyState <> READYSTATE_COMPLETE)
' Allow mouse clicks and such while info is being scraped from internet ... Create a delay to allow the webpage to fully load before proceeding
Application.Wait (Now + TimeValue("00:00:01")) ' Delay for x seconds
DoEvents
Loop
'
Dim Doc As HTMLDocument
Set Doc = IE.document
'
Application.StatusBar = "Gathering Data from website … https://www.poloniex.com/exchange#btc_dgb" ' Update status bar to inform the user of what is occurring
'
' Return SellPrice
Range("poloniex_SellPrice_1").Value = Doc.getElementsByTagName("td")(3).innerText ' <--- This line is InCorrect
'
' Return BuyPrice
Range("poloniex_BuyPrice_1").Value = Doc.getElementsByTagName("td")(2).innerText ' <--- This line is InCorrect
'
'-----------
'
Any help from the members here would be most greatly appreciated!