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



## johnnyL (Mar 18, 2019)

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!


----------



## mrshl9898 (Mar 18, 2019)

https://stackoverflow.com/questions/5915325/open-google-chrome-from-vba-excel


```
<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"""


----------



## johnnyL (Mar 18, 2019)

mrshl9898 said:


> https://stackoverflow.com/questions/5915325/open-google-chrome-from-vba-excel
> 
> 
> ```
> ...



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:


```
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:

```
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?


----------



## johnnyL (Mar 19, 2019)

johnnyL said:


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



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


```
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.


----------



## johnnyL (Mar 23, 2019)

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.


----------

