0

I have been using the following Excel VBA macro to bring back data from a website. It worked fine until a few days ago when the website stopped supporting IE. Of course the macro just fails now as there is no data on the webpage to bring back to Excel, Is there a way to have the "Get method" (MSXML2.XMLHTTP)

here is my Code

    Public Sub GGGG()
        Dim MSX As Object
        Dim HTML As HTMLDocument
        Dim URL As String
        Dim UrlResponse As String
        Dim N As Long
        Dim sht1, sht2 As Worksheet

       ' On Error Resume Next
        Set MSX = CreateObject("MSXML2.XMLHTTP")
        Set HTML = New HTMLDocument
        

        URL = "https://www.justdial.com/Agra/Yogi-General-Store-Opp-Eclave-Satiudum-Sadar-Bazaar/0562P5612-5612-120207212812-H5I2_BZDET"
                    
                    With MSX
                        .Open "GET", URL, False
                        .setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
                        .send
                        UrlResponse = StrConv(.responseBody, vbUnicode)
                    End With

                       ActiveCell.Offset(0, 1) = UrlResponse

                    
    End Sub

I get response like

Error An error occurred while processing your request.

Reference #97.ec8a2c31.1621136928.281f3ca8

Please anyone can support me how to get data when IE dose not support I am not an expert in coding

18
  • 1
    It is the website not the browser. Commented May 16, 2021 at 5:18
  • 1
    I tried a variety of browsers and non browser methods to no avail. Commented May 16, 2021 at 6:40
  • 2
    As I think it is the website I would say no. I tried in different languages - same result. Whether it affects all users or region based, I don't know. I suspect strongly it is the site. Commented May 16, 2021 at 7:03
  • 1
    Try navigating to that page via a search on the home page. Commented May 16, 2021 at 7:51
  • 1
    The correct url for me is to use https://www.justdial.com/Agra/Yogi-General-Store-Sadar-Bazaar/0562P5612-5612-120207212812-H5I2_BZDET That works fine across browsers except IE. Commented May 16, 2021 at 10:31

3 Answers 3

1

Okay, try this to get the title and votes from that site using vba in combination with selenium.

Sub FetchInfo()
    Dim driver As Object, oTitle As Object
    Dim oVotes As Object
    
    Set driver = CreateObject("Selenium.ChromeDriver")
    
    driver.get "https://www.justdial.com/Agra/Yogi-General-Store-Opp-Eclave-Satiudum-Sadar-Bazaar/0562P5612-5612-120207212812-H5I2_BZDET"
    Set oTitle = driver.FindElementByCss("span.item > span", Raise:=False, timeout:=10000)
    Set oVotes = driver.FindElementByCss("span.rtngsval > span.votes", Raise:=False, timeout:=10000)
    Debug.Print oTitle.Text, oVotes.Text
End Sub
Sign up to request clarification or add additional context in comments.

Comments

0

When the webpage no longer support IE in future, you can try out web scrape using Google Chrome with new add-in installed, please see following link for the add-in installation adn how to write in VBA. However, it is in my opinion the most simple way to perform your work is to use Uipath free community version, it work for all type of web-browser.

VBA guideline: https://www.wiseowl.co.uk/vba-macros/videos/vba-scrape-websites/web-scraping-selenium-chrome/

VBA library installation for Selenium: https://code.google.com/archive/p/selenium-vba/downloads

2 Comments

I try with selenium Chrome ... same issue still going on
Quite bad to hear it, if VBA is giving you alot trouble, there is other tools that can always help you. Come with Web automation, VBA not always my preferred tool. Good luck and hope you can solve the problem!!
0

You probably need to set the Feature Browser Emulation to zero as detailed by Daniel here:

Everything You Never Wanted to Know About the Access WebBrowser Control

That said, your URL fails even when opened in Edge Chromium, so the site may suffer from a general failure.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.