0

I'm trying to get any response from a webpage using xmlhttp requests in vba. Whenever I try to execute the following script, I get this same message The system can't locate the resource specified.

Sub GetTitle()
    Const URL$ = "https://jow.com/recipes/roasted-eggplant-with-yogurt-sauce-80uf18xsg48w043m0g4y/print"

    Dim Html As HTMLDocument
    
    Set Html = New HTMLDocument

    With CreateObject("MSXML2.XMLHTTP")
        .Open "Get", URL, False
        .setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"
        .send
        Html.body.innerHTML = .responseText
    End With

    MsgBox Html.querySelector("h1").innerText

End Sub

How can I get rid of that aforementioned message and fetch any response from that webpage using xmlhttp requests?

MITHU
  • 167
  • 3
  • 10
  • 32
  • Your code works for me; The msgbox shows 'Roasted Eggplant with Yogurt Sauce'. Perhaps take a look at this thread: https://stackoverflow.com/questions/4041687/msxml-the-system-cannot-locate-the-resource-specified – Slaqr Oct 21 '21 at 21:20
  • I can open the URL with a web browser, and I got the same error as OP with code above, but it worked fine for a different URL. Could it be something to do with the server detecting a type of client that is not supported? – JohnRC Oct 21 '21 at 21:30
  • Probably a networking issue on the client machine, this code works fine – Ryan Wildry Oct 21 '21 at 22:58

0 Answers0