Speed of multiple URL web scraping

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
4,546
Office Version
  1. 2007
Platform
  1. Windows
Need some help with this code.

1) The current code leaves a bunch of IE windows open.
2) The current code leads to a Run-time error '-2147437259 (80004005)':
3) It takes forever to run, Hopefully someone can assist me in converting it to use MSXML2.XMLHTTP60 for example, I heard that works faster.


Code:
'
'-----------------------------------------------------
'   Run-time error '-2147437259 (80004005)':    ' This Error Occurs, eventually, in the 'Yahoo_One_Year_Estimates_Scrape_Error' section \/ \/ \/
'                                                   Also many internet explorer windows are left open that should have been closed
'
'   Automation Error
'   Unspecified Error
'-----------------------------------------------------
'
'
'   Global Variables That will be used
'
    Public Doc                                      As HTMLDocument
'
    Public StockMainPageURL                         As String       ' This will be the main portion of the URL that we send to Internet Explorer
    Public TotalURL                                 As String       ' This will be the complete URL that we send to Internet Explorer
'
    Public CellCounter                              As Integer      ' This will be used to adjust left to right on web site cells
    Public RowCounter                               As Integer      ' This adjusts the offset from the top of the spreadsheet to the start of the columns
    Public StockCount                               As Integer      ' This counts the actual stocks being analyzed currently
    Public TotalStocksToLoad                        As Integer      ' This counts the stocks that should be analyzed right now
'
    Public PageLoadAttempt                          As Long         ' This counts the number of times we have tried to load a page
'
'-------------------------------------------------------------------------------------------------------------------------------
'
Private Sub RefreshEntireDocument_Click()
'
'   This will Clear certain cell values in the spreadsheet when the $B$1 'Refresh' cell is clicked
'
    Range("$B$5:$K$254").Select                                 ' Select the range of $B$5 thru $J$254
    Selection.ClearContents                                     ' Delete the contents of this range
'
'
' -------------------------------------------------------------------------------------------------------------------------
'
'   Scrape stocks to consider looking into further from 1st URL page
'
    RowCounter = 5                                              ' Start loading stock values recieved into the 5th row of Excel
    MaxYahooDelay = 0                                           ' Initialize MaxYahooDelay = 0
'
    CellCounter = 0                                             ' Left to right cell counter
    PageLoadAttempt = 0                                         ' Initialize PageLoadAttempt = 0
    TotalStocksToLoad = 100                                     ' we will Scrape this amount of stocks from the 1st loaded page of stocks
'
    Call Scrape_BarChart_Stock_Page_1                           ' Scrape the amount of TotalStocksToLoad into excel
'
' -------------------------------------------------------------------------------------------------------------------------
'
'   Scrape stocks to consider looking into further from 2nd URL page
'
    CellCounter = 0                                             ' Left to right cell counter
    PageLoadAttempt = 0                                         ' Initialize PageLoadAttempt = 0
    TotalStocksToLoad = 100                                     ' we will Scrape this amount of stocks from the 2nd loaded page of stocks
'
    Call Scrape_BarChart_Stock_Page_2                           ' Scrape the amount of TotalStocksToLoad into excel
'
' -------------------------------------------------------------------------------------------------------------------------
'
'   Scrape stocks to consider looking into further from 3rd URL page
'
    CellCounter = 0                                             ' Left to right cell counter
    PageLoadAttempt = 0                                         ' Initialize PageLoadAttempt = 0
    TotalStocksToLoad = 50                                      ' we will Scrape this amount of stocks from the 3rd loaded page of stocks
'
    Call Scrape_BarChart_Stock_Page_3                           ' Scrape the amount of TotalStocksToLoad into excel
'
' -------------------------------------------------------------------------------------------------------------------------
' -------------------------------------------------------------------------------------------------------------------------
'
'   Scrape values from Yahoo to Update the one year estimates from previous pages of stocks scraped
'
    RowCounter = 5                                              ' Start loading stock values recieved into the 5th row of Excel
    PageLoadAttempt = 0                                         ' Initialize PageLoadAttempt = 0
    TotalYahooDelay = 0                                         ' Initialize TotalYahooDelay = 0
    TotalYahooPageAttempts = 0                                  ' Initialize TotalYahooPageAttempts = 0
    TotalStocksToLoad = 250                                     ' we will Scrape this amount of stocks from the 3rd loaded page of stocks

    Call Scrape_Yahoo_One_Year_Estimates                        ' Scrape the amount of TotalStocksToLoad into excel
'
' -------------------------------------------------------------------------------------------------------------------------
'
'   Display some final results in the status bar
    Application.StatusBar = "Spreadsheet Refreshing Complete :)" ' & "    Avg Yahoo Delay = " & AvgYahooDelay & "     Avg Yahoo Page Attempts = " & AvgYahooPageAttempts
'
End Sub
'-------------------------------------------------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------------------------------------------------
'
Private Sub Scrape_Yahoo_One_Year_Estimates()                       ' *** Good up to here ***
'
'
    For StockCount = 1 To TotalStocksToLoad                         ' Grab One Year stock price estimate
'
'
ReloadScrape_Yahoo_One_Year_Estimates:
'
'       Load all of the Update one year estimates
        DelaySeconds = 0                                            '   Initialize DelaySeconds to zero
        PageLoadAttempt = PageLoadAttempt + 1                       '   Add 1 to our PageLoadAttempt counter
''''        TotalYahooPageAttempts = TotalYahooPageAttempts + 1         '   This will be the total yahoo Page Attempts
'
        StockMainPageURL = "finance.yahoo.com/quote/"               '   This will be the main portion of the URL that we send to Internet Explorer
        CurrentStockSymbol = Trim(Range("B" & RowCounter).Value)    '   This is the stock symbol that we will be addressing
'
'       Setup and Load the Internet Explorer Page ...
''''        Dim IE As New SHDocVw.InternetExplorer  ' This works
        Dim IE As New InternetExplorer
''      Dim IE As MSXML2.XMLHTTP60
''      Set IE = New MSXML2.XMLHTTP60
'
        TotalURL = "https://" & StockMainPageURL & CurrentStockSymbol   ' This will be the complete URL that we send to Internet Explorer
'
        If CurrentStockSymbol = 0 Or CurrentStockSymbol = "" Or IsEmpty(CurrentStockSymbol) = True Then ' If no stock symbol found @ $B?  then ...
            PageLoadAttempt = 0                                                                         '   Reset PageLoadAttempt = 0
            StockCount = TotalStocksToLoad                                                              '   Indicate no more stocks to load
'
            IE.Quit                                                                                     '   Close Internet Explorer Window
            Set IE = Nothing                                                                            '   Clear Internet Explorer Memory
'
            Exit Sub                                                                                    '   Exit this sub
        Else
'
            On Error GoTo Yahoo_One_Year_Estimates_Scrape_Error                                         '   If Error occurs then goto Yahoo_One_Year_Estimates_Scrape_Error
'
            Set IE = New InternetExplorer                                                               '   Open Internet Explorer Browser
'
'           Browser address that we will be scraping values from
            IE.navigate TotalURL                                                                        '   Load the Internet Explorer URL
'
'           Make the Browser window, that we will be scraping values from, visible
            IE.Visible = True                                           '   Make Internet Explorer Windows Visible
'
'           Allow mouse clicks and such while browser window is loading ... Loop until browser window is fuilly loaded, ie. READYSTATE_COMPLETE
            Do While IE.readyState <> 4 And DelaySeconds <= 19                                          '   Loop while IE is still loading and <= 19 seconds delayed
''              Application.Wait DateAdd("s", 1, Now)
                Application.Wait (Now + TimeValue("00:00:01"))                                          '   Delay for 1 second
                DoEvents                                                                                '   Enable Mouse Clicks
'
'               Update status bar to inform the user of what is occurring
                Application.StatusBar = "Loading website … " & TotalURL & "    Stock # " & (RowCounter - 4) ''''& _
''''                                "   Delay Seconds =  " & DelaySeconds & "    Page Load Attempts = " & PageLoadAttempt & _
''''                                "   Avg Yahoo Delay = " & AvgYahooDelay & "     AvgYahooPageAttempts = " & AvgYahooPageAttempts
'
                DelaySeconds = DelaySeconds + 1                         '   Add 1 to our DelaySeconds Counter
'
''''                If DelaySeconds > MaxYahooDelay Then MaxYahooDelay = DelaySeconds   '   Save the MaxYahooDelay
''                  TotalYahooDelay = TotalYahooDelay + 1
'
            Loop                                                        ' Loop back
'
'           Allow mouse clicks and such while browser window is loading ... Loop until browser window is fuilly loaded, ie. READYSTATE_COMPLETE
            Do While IE.Busy And DelaySeconds <= 19 ' Or IE.readyState <> 4 And DelaySeconds <= 19  ' Loop while IE is still loading and <= 19 seconds delayed
''              Application.Wait DateAdd("s", 1, Now)
                Application.Wait (Now + TimeValue("00:00:01"))          '   Delay for 1 second
                DoEvents                                                '   Enable Mouse Clicks
'
'               Update status bar to inform the user of what is occurring
                Application.StatusBar = "Loading website … " & TotalURL & "    Stock # " & (RowCounter - 4) ''''& _
''''                                "   Delay Seconds =  " & DelaySeconds & "    Page Load Attempts = " & PageLoadAttempt & _
''''                                "   Avg Yahoo Delay = " & AvgYahooDelay & "     AvgYahooPageAttempts = " & AvgYahooPageAttempts
'
                DelaySeconds = DelaySeconds + 1                         '   Add 1 to our DelaySeconds Counter
'
''''                If DelaySeconds > MaxYahooDelay Then MaxYahooDelay = DelaySeconds   '   Save the MaxYahooDelay
            Loop                                                        ' Loop back
'
'
            If DelaySeconds > 19 Then                                   ' If we have delayed for > 19 seconds to allow the page to load then ...
                IE.Quit                                                 '   Close Internet Explorer Window
'
                If PageLoadAttempt <= 4 Then GoTo ReloadScrape_Yahoo_One_Year_Estimates '   If we have'nt tried 4 reloads of this page then reload page again
            End If                                                      ' End If
'
            If PageLoadAttempt > 4 Then                                 ' If we have tried 4 reloads of the URL page then Display a message box & Exit program
                MsgBox "We've reloaded the same web page  " & PageLoadAttempt & " times without success so we're going to pause the program" & _
                " so you can investigate.", , "Multiple errors detected"
'
                PageLoadAttempt = 0                                     '   Reset PageLoadAttempt = 0
'
                Stop                                                    '   Stop this Excel program!
            End If
'
            Set Doc = IE.document
'
        End If
'
'
''''        TotalYahooDelay = TotalYahooDelay + DelaySeconds
''''        AvgYahooDelay = TotalYahooDelay / (RowCounter - 4)
''''        AvgYahooPageAttempts = TotalYahooPageAttempts / (RowCounter - 4)
'
'       Update status bar to inform the user of what is occurring
        Application.StatusBar = "Gathering Data from website … " & TotalURL & "    Stock # " & (RowCounter - 4) ''''& _
''''                                "   Delay Seconds =  " & DelaySeconds & "    Page Load Attempts = " & PageLoadAttempt & _
''''                                "   Avg Yahoo Delay = " & AvgYahooDelay & "    AvgYahooPageAttempts = " & AvgYahooPageAttempts
'
        Range("J" & RowCounter).Value = Doc.getElementsByTagName("td")(11).innerText        '   Scrape the Yahoo 52 Week Price Range
        Range("K" & RowCounter).Value = Doc.getElementsByTagName("td")(31).innerText        '   Scrape the Yahoo One Year Price Estimate
'
        On Error GoTo 0                                                                     '   Clear Errors & Set Excel Error handling to Default
'
        RowCounter = RowCounter + 1                                                         '   Advance to next row in Excel sheet
'
        IE.Quit                                                                             '   Close Internet Explorer Window
        Set IE = Nothing                                                                    '   Clear Internet Explorer Memory
'
        PageLoadAttempt = 0                                                                 '   Reset PageLoadAttempt = 0
'
    Next                                                                                    '   Load next stock until all are loaded
'
    Exit Sub                                                                                ' Exit this Sub
'
Yahoo_One_Year_Estimates_Scrape_Error:
'
'   Tried this solution from google \/ \/ to solve errors, No luck :(                       ' Shut down all Internet Explorer windows
''    Dim wsh As Object
''    Dim windowStyle As Integer: windowStyle = 1
''    Dim waitOnReturn As Boolean: waitOnReturn = True
'
''    Set wsh = VBA.CreateObject("Wscript.Shell")
''    wsh.Run "taskkill /F /IM iexplore.exe", windowStyle, waitOnReturn
'
'
'
''    IE.Quit                                                                             '   Close Internet Explorer Window
    Set IE = Nothing                                                                    '   Clear Internet Explorer Memory
'
'   This works some what
    Set IE = New InternetExplorer                                                           ' Open Internet Explorer Browser
'
'
    Resume Next                                                                             ' Go back to the next line after the previous error occurred
'
End Sub
'________________________________________________________________________________________________________________________________________________________
 
So, "headless browser" seems to be my next path to look into.

Since the site I want to scrape from is "java enabled", any recommendations?

I have never used this approach, so I have googled it some today. From what I read, I gather that some additional software needs to be installed and then reference added in Excel? Or can it be done in excel without 3rd party addon?

Again, many thanks for all of the support thus far !!!
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi - as I said the other day, you should just stick with Internet Explorer. MSXML is not going to help, because it doesn't render the Javascript, but Internet Explorer does...

I tried it with the revised code you posted the other day and it works perfectly fine. In fact, if you used your code from the other day rather than the original code you posted, you won't encounter all the problems that you had before with the opening dozens of instances of Internet Explorer. Give me 15 minutes and I'll send you some updated code.
 
Upvote 0
Ok. I just maded a few slight amendments to the revised code you posted. It only opens one instance of IE, with visibility off, and makes it navigate to the three Barchart URLs - you will need to fill in the other two URLs (TotalURL(2) = "https://www.barchart.com/stocks/performance/...", etc.)

VBA Code:
Private Sub Scrape_BarChart_Stock_Pages()    ' Currently not working !!!
'
'   Scrape stocks to consider looking into further from 1st URL page
'
    Dim StockMainPageURL        As String          ' This will be the main portion of the URL that we send to Internet Explorer
    Dim RowCounter              As Integer         ' This adjusts the offset from the top of the spreadsheet to the start of the columns
    Dim CellCounter             As Integer         ' This will be used to adjust left to right on web site cells
    Dim TotalStocksToLoad       As Integer         ' This counts the stocks that should be analyzed right now
    Dim StockCount              As Integer         ' This counts the actual stocks being analyzed currently
    Dim TotalURL(1 To 3)        As String          ' This will be the complete URL that we send to Internet Explorer
    Dim strHTML                 As String          '
    Dim Doc                     As New HTMLDocument    '
    Dim IE                      As New InternetExplorer
    
'   Turn visibility off
    IE.Visible = False

    RowCounter = 5                                              ' Start loading stock values recieved into the 5th row of Excel
    CellCounter = 0                                             ' Left to right cell counter on Web page
    TotalStocksToLoad = 100                                     ' we will Scrape this amount of stocks from the 1st loaded page of stocks
'
'   URL of 1St page of stocks that we will scrape from
    TotalURL(1) = "https://www.barchart.com/stocks/performance/percent-change/declines?timeFrame=3m&viewName=main"
    TotalURL(2) = "https://www.barchart.com/stocks/performance/..."
    TotalURL(3) = "https://www.barchart.com/stocks/performance/..."

    For counter = 1 To 3

    '   Browser address that we will be scraping values from
        IE.navigate TotalURL(counter)
        
'       Allow mouse clicks and such while browser window is loading ... Loop until browser window is fuilly loaded, ie. READYSTATE_COMPLETE
        Do While IE.readyState <> 4
            DoEvents
        Loop
    Set Doc = IE.Document
'   Update status bar to inform the user of what is occurring
    Application.StatusBar = "Gathering Data of stocks to load website Page 1 … "
'
    For StockCount = 1 To TotalStocksToLoad                                                         ' Grab stock names & some values
'
        Range("A" & RowCounter).value = (RowCounter - 4)                                            '   Stock number Counter
        Range("B" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter).innerText       '   Stock Symbol
        Range("C" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter + 1).innerText   '   Stock Name
        Range("D" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter + 2).innerText   '   3 Month % Change
        Range("E" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter + 3).innerText   '   Last Price
        Range("F" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter + 4).innerText   '   Change
        Range("G" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter + 5).innerText   '   % Change
        Range("H" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter + 7).innerText   '   3 Month High
        Range("I" & RowCounter).value = Doc.getElementsByTagName("td")(CellCounter + 8).innerText   '   3 Month Low
'
        CellCounter = CellCounter + 12                                                              '   Advance to next row on URL page
        RowCounter = RowCounter + 1                                                                 '   Advance to next row in Excel sheet
'
    Next
Next

IE.Quit
Set IE = Nothing
End Sub
 
Upvote 0
Alternatively, you could always just download the Excel spreadsheets with the data on them, already set out for you ;)
BarCharts appear to have a free membership tier which allows you up to 5 downloads of data a day - here are links to the declines and advances for 3m: Barchart Spreadsheets

Also, the do in fact have a free API, and rather helpfully give you step-by-step instructions on how to retrieve the data through the API in - wait for it... - Excel! And without any coding at all! And it gets better - their method for accessing the data is - wait for it - Power Query! Which is precisely what
@lrobbo314 recommended! You gotta laugh...
1599374260422.png
 
Upvote 0
Alternatively, you could always just download the Excel spreadsheets with the data on them, already set out for you ;)
BarCharts appear to have a free membership tier which allows you up to 5 downloads of data a day - here are links to the declines and advances for 3m: Barchart Spreadsheets

Also, the do in fact have a free API, and rather helpfully give you step-by-step instructions on how to retrieve the data through the API in - wait for it... - Excel! And without any coding at all! And it gets better - their method for accessing the data is - wait for it - Power Query! Which is precisely what
@lrobbo314 recommended! You gotta laugh...
View attachment 21788

Nice. Hey, there are definite pros and cons to each. There are times that you just have to use VBA. Especially when it comes to PQ; some sites just don't play nicely.

But yeah, don't sleep on PowerQuery. It's an insanely powerful tool to have on tap.
 
Upvote 0
Geesh, where do I start after all of those responses?

Dan_W
Basically, the Barcharts site is Javascript-rendered - this means that sourcing the HTML code with MSXML is not going to help on this ooccasion. Instead, you will need to automate a browser to first render and populate the site with the data, and then extract the code from which to scrape. This could be done by a API, a headless browser or, as is the case in your original code, Internet Explorer.

I thought, from your response there, that perhaps a headless browser might be worth looking into, but then you later said ...
Dan_W
Hi - as I said the other day, you should just stick with Internet Explorer. MSXML is not going to help, because it doesn't render the Javascript, but Internet Explorer does...

I am so confused.

I certainly welcome any code submissions from any of the members here. I got a few ideas from your most recent code submission Dan_W. Thank you so much for that!
The code had a couple errors in it as you submitted, but I worked those out to get it to run. :)

VBA Code:
'
'   Turn visibility off
    IE.Visible = False
'
    RowCounter = 5                                              ' Start loading stock values recieved into the 5th row of Excel
''    CellCounter = 0                                             ' Left to right cell counter on Web page
    TotalStocksToLoad = 100                                     ' we will Scrape this amount of stocks from the 1st loaded page of stocks
'
'   URLs of pages of stocks that we will scrape from
    TotalURL(1) = "https://www.barchart.com/stocks/performance/percent-change/declines?timeFrame=3m&viewName=main"
    TotalURL(2) = "https://www.barchart.com/stocks/performance/percent-change/declines?timeFrame=3m&viewName=main&page=2"
    TotalURL(3) = "https://www.barchart.com/stocks/performance/percent-change/declines?timeFrame=3m&viewName=main&page=3"
'
    For counter = 1 To 3
'
        If counter = 3 Then TotalStocksToLoad = 50
        CellCounter = 0                                             ' Left to right cell counter on Web page

Basically the CellCounter reset to 0 needs to be within the For/Next Loop and the 3rd page that loads the stocks only has 50 stocks, so that had to be corrected also. I made a couple of other cosmetic changes but no biggie there.

I no longer have the extraneous Explorer windows left open after all of my recent googling and the code submissions here. :)

The reason I was pondering my next step is because the 3rd phase of my program requires each of the 250 stocks that were loaded into excel get loaded into yet another BarChart URL separately, for analyst ratings.

I have looked at BarChart free API service and it doesn't cover this.

Barchart’s free market data API only allows for both getQuote and getHistory APIs. Any additional APIs require a paid subscription to Barchart OnDemand. For pricing, please contact solutions@barchart.com

Every user is able to make 400 getQuote queries and 150 getHistory queries per day.

Maybe I am missing something, but that is what my searching found.

I don't even want to mention my 4th and final wish because I doubt it can even be done, scrape data from a picture graph, but like I said, I doubt that can be done.

I have rambled long enough, my appologies, many thanks to all that have contributed!
 
Upvote 0
I am so confused.
Understandably. Of course, I know what I mean when I say things, but I appreciate that not everyone in the world can read my mind. Sorry. The point I was making (trying to make?) in the first comment was that there were (at least?) three ways to get that data - an API, a headless browser or Internet Explorer (which is the way your original code had accomplished the task). What I should've done is continued that point to then say "So in this respect, you should just keep using IE for BarCharts."
The code had a couple errors in it as you submitted, but I worked those out to get it to run.
Ahh yes, I should've added in my post that I didn't know how/if you were going to integrate the different strands of code, so some adjustments might be needed (namely, to any variables you were planning to use). Glad you were able to fix it.
no longer have the extraneous Explorer windows left open after all of my recent googling and the code submissions here.
That's great - and that really was my primary goal. First time I read your code, I was quietly panicking at just how many Internet Explorers could potentially be loaded and what a drain on resources that would be.
Maybe I am missing something, but that is what my searching found.
As you say, the API doesn't sound like the right fit for you. In my defense, I didn't actually know what it is that you wanted or indeed what you were planning on doing with any of this :)
I don't even want to mention my 4th and final wish because I doubt it can even be done, scrape data from a picture graph, but like I said, I doubt that can be done.
I really couldn't say (especially without looking at the source website), but it sounds potentially very difficult. Of course, there are people far more intelligent that will say it's easy, so take everything I say with a pinch of salt. Is it the actual underlying data from the picture graph you would need, or would a screen capture suffice? A screen capture would be easier to do.

From all that I've managed to discern, I wonder whether you might want to look at Selenium as a potential solution for your future webscraping projects? Also, when you get the chance, I'd strongly recommend looking at using APIs in future. Though I understand for the reasons you set out above that it doesn't work for you now, they are very helpful and there are some excellent resources out there to teach you how to go about using them:
Sigma Coding (YouTube), Wise Owl (YouTube), Wellsr.
 
Upvote 0
Hey Dan_W! Thank you for clearing up my confusion. I certainly meant no disrespect to you or anyone else.

As far as the highly doubtful 4th scenario of being able to scrape values from a photo, below is some links I am referring to ...
VBA Code:
https://money.cnn.com/quote/quote.html?symb=amzn    ' Original Site with forecasts picture of 12 Month Low/Medium/High Forecasts
https://markets.money.cnn.com/cgi-bin/upload.dll/file.png?z6f8f7c0az673a4558dda64d6cb34d5a8c5f049534    ' Link to actual Forecasts png file on the above page

I would desire to capture the Low/Medium/High values, but like I said, I am not holding my breath on getting that from a png file. :(

I have briefly looked at Selenium as it relates to integrated into Excel, not sure if that will help though. I have also looked briefly into API's, but my search was brief when I saw from my reading that a subscription was required for the site that I was interested in. :(

Power Query sounds interesting, but it looks like a completely different language that I would have to learn, maybe I am wrong on that.

I am going to see what I can do with the 3rd phase of my current project with IE. I have it running error free, but I want to increase the speed of the 3rd phase. :)
 
Upvote 0
I certainly meant no disrespect to you or anyone else.
No, no - sorry, I didn't mean to suggest anything like that.

I had a look at the image you referenced. I'd say it's doable. The URL for the image will constantly changing, but it helpfully sits within a div element with the class name "clearfix" - and that's unlikely to change. You would need to then run that image through an OCR process (there are OCR APIs available, or you could install software like Tesseract on your computer) and parse the resulting text to pull out the three figures. It's best to: (1) work out whether something can be accomplished manually; (2) set out the process into a number of steps; and then (3) work out how to do each of those steps programatically.

Though the question you ought to ask yourself is this:- is this the best (or only) source of this particular data? Have you looked into alternatives? Exhibit A and Exhibit B.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top