XMLHTTP problems

L_P

New Member
Joined
Dec 3, 2011
Messages
3
I'm trying to extract data from some webpages. I'm pulling in the html with an XMLHTTP object and extracting the desired information with Regex.

The following code works fine for vanilla ".html" pages:
Code:
    Dim pageHTML As String
    Dim oXMLHTTP As Object
    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
    :
    :
    oXMLHTTP.Open "GET", urlString, False
    oXMLHTTP.send ""
            
    If oXMLHTTP.Status <> 200 Then
        errorStr = oXMLHTTP.statusText
        GoTo HandleError
    Else
        htmlStr= oXMLHTTP.responseText
    End If
In that case, I get the full html code into htmlStr, whence I can extract the desired info.



:mad: BUT :mad:


When I try it on other sorts of pages, such as .asp and .php, all I get in oXMLHTTP.responseText is a "html" tag.

I'm trying to parse simple pages - ones that take no variables or parameters. E.g.: http://www.quoteland.com/random.asp . I just want to get back the html code that shows up as the page source in my browser when I surf to such sites.


After several hours of searching the web, all I've been able to come up with is that maybe I need to do something with setRequestHeader. Or maybe I need some sort of "POST" rather than "GET". Or something.

Nowhere have I been able to find a simple explanation of the XMLHTTP functionality, nor instructions on how I need to configure the object in order to get the HTML code generated by .asp, .php, and similarly flavored URLs.



Um.... HELP?!!! :confused:


Thanks,
LP
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
"Nowhere have I been able to find a simple explanation of the XMLHTTP functionality"

Tell me about it!!! I found out about it a couple of days ago and the only thing online I can find are "this is how to go to a page and get the results" ??? I don't think hardly any of the experts even know how to use xmlhttp in vba. Frustrating!
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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