Requested Help with changing default Web browser for Macro web site scraping

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
4,546
Office Version
  1. 2007
Platform
  1. Windows
I have done many google searches for trying to change macro web site scraping code from using Internet Explorer as the default web browser to an alternative web browser for scraping data. Unfortunately, all I have found is changing the web browser for hyperlinks in an excel cell.

Is there a way to instruct macro code to use an alternative web browser for a web site prior to scraping data from it?

I would assume it might involve including the path to the web browser in addition to the web site address that is desired to scrape data from.

Any help in this would be most appreciated because a few web sites that I want to scrape data from will not load with Internet Explorer.

Thank You!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
https://stackoverflow.com/questions/5915325/open-google-chrome-from-vba-excel

Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">[COLOR=#101094][FONT=inherit]Sub[/FONT][/COLOR][COLOR=#303336][FONT=inherit] test544[/FONT][/COLOR][COLOR=#303336][FONT=inherit]()[/FONT][/COLOR][COLOR=#303336][FONT=inherit]

  [/FONT][/COLOR][COLOR=#101094][FONT=inherit]Dim[/FONT][/COLOR][COLOR=#303336][FONT=inherit] chromePath [/FONT][/COLOR][COLOR=#101094][FONT=inherit]As[/FONT][/COLOR][COLOR=#101094][FONT=inherit]String[/FONT][/COLOR][COLOR=#303336][FONT=inherit]

  chromePath [/FONT][/COLOR][COLOR=#303336][FONT=inherit]=[/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"""C:\Program Files\Google\Chrome\Application\chrome.exe"""[/FONT][/COLOR][COLOR=#303336][FONT=inherit]

  Shell [/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#303336][FONT=inherit]chromePath [/FONT][/COLOR][COLOR=#303336][FONT=inherit]&[/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]" -url http:google.ca"[/FONT][/COLOR][COLOR=#303336][FONT=inherit])[/FONT][/COLOR][COLOR=#303336][FONT=inherit]
 [/FONT][/COLOR]</code>[COLOR=#101094][FONT=inherit]End[/FONT][/COLOR][COLOR=#101094][FONT=inherit]Sub[/FONT][/COLOR]

*I needed to use: chromePath = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""
 
Last edited:
Upvote 0
https://stackoverflow.com/questions/5915325/open-google-chrome-from-vba-excel

Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">[COLOR=#101094][FONT=inherit]Sub[/FONT][/COLOR][COLOR=#303336][FONT=inherit] test544[/FONT][/COLOR][COLOR=#303336][FONT=inherit]()[/FONT][/COLOR][COLOR=#303336][FONT=inherit]

  [/FONT][/COLOR][COLOR=#101094][FONT=inherit]Dim[/FONT][/COLOR][COLOR=#303336][FONT=inherit] chromePath [/FONT][/COLOR][COLOR=#101094][FONT=inherit]As[/FONT][/COLOR][COLOR=#101094][FONT=inherit]String[/FONT][/COLOR][COLOR=#303336][FONT=inherit]

  chromePath [/FONT][/COLOR][COLOR=#303336][FONT=inherit]=[/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"""C:\Program Files\Google\Chrome\Application\chrome.exe"""[/FONT][/COLOR][COLOR=#303336][FONT=inherit]

  Shell [/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#303336][FONT=inherit]chromePath [/FONT][/COLOR][COLOR=#303336][FONT=inherit]&[/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]" -url http:google.ca"[/FONT][/COLOR][COLOR=#303336][FONT=inherit])[/FONT][/COLOR][COLOR=#303336][FONT=inherit]
 [/FONT][/COLOR]</code>[COLOR=#101094][FONT=inherit]End[/FONT][/COLOR][COLOR=#101094][FONT=inherit]Sub[/FONT][/COLOR]

*I needed to use: chromePath = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""

Thank you so much mrshl9898 for your quick response to my question!

I have checked out the link that you provided and came up with the following to open up an an alternative browser to Internet Explorer via macro code:

Code:
Shell ("C:\Program Files\Mozilla Firefox\firefox.exe -url https://www.coinexchange.io/market/DGB/BTC")

That code does open the alternative browser, via Excel macro code, that I am wishing to use, however, I am not sure how to scrape the data after that page loads. :(

The Internet Explorer code that I have successfully used previously is:
Code:
        Dim IE As New InternetExplorer
        Dim element As Object
'
'       Make the Browser window, that we will be scraping values from, visible
        IE.Visible = True
'
'       Browser address that we will be scraping values from
        IE.navigate "https://www.coinexchange.io/market/DGB/BTC"
'
'   Loop until ...
        Do While (IE.Busy Or IE.readyState <> READYSTATE_COMPLETE)
'           Allow mouse clicks and such while info is being scraped from internet ... Prevents Excel freezing
            Application.Wait (Now + TimeValue("00:00:01"))
            DoEvents
        Loop
'
        Dim Doc As HTMLDocument
        Set Doc = IE.document
'
'       Return SellPrice
        Range("coinexchange.io_SellPrice_1").Value = Doc.getElementsByTagName("td")(3).innerText
'
'       Return BuyPrice
        Range("coinexchange.io_BuyPrice_1").Value = Doc.getElementsByTagName("td")(2).innerText

Any ideas from anyone to proceed with the web scraping with the alternative browser?
 
Last edited:
Upvote 0
Code:
Shell ("C:\Program Files\Mozilla Firefox\firefox.exe -url https://www.coinexchange.io/market/DGB/BTC")

That code does open the alternative browser, via Excel macro code, that I am wishing to use, however, I am not sure how to scrape the data after that page loads. :(

...

Any ideas from anyone to proceed with the web scraping with the alternative browser?

Small amount of progress on my end today. I also got the following code to open a firefox browser/webpage:

Code:
   Dim objShell

   Set objShell = CreateObject("WScript.Shell")

    objShell.Run """C:\Program Files\Mozilla Firefox\firefox.exe""https://www.coinexchange.io/market/DGB/BTC"

   Set objShell = Nothing

I am still trying to figure out how to webscrape data once that firefox browser/webpage opens. :(
 
Upvote 0
Well after much googling, it appears that browsers other than internet explorer are not set up to handle scraping. There are limited things that can be done, but web scraping, apparently, is not possible via excel. :(
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,143
Members
453,021
Latest member
Justyna P

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