Link to home
Start Free TrialLog in
Avatar of jhattingh
jhattingh

asked on

VBA: How to use firefox instead of IE when reading http response?

In the code snippet, you can see that I want to read the http response. It works ok, but I am reading from an intranet-based web app that doesn't support IE. I need to use FireFox or some "generic" web browsing.

Thanks in advance.
Dim http As New MSXML.XMLHTTPRequest
http.Open "post", "http://www.advfn.com/blah,blah,blah", False, "Username", "Password"
http.send
Str = http.responseText

Open in new window

Avatar of Badotz
Badotz
Flag of United States of America image

Well, if you are using AJAX, I don't see where the browser fits in at all. Unless your snippet doesn't work in IE?

I'm not sure what you are asking, I guess...
Avatar of jhattingh
jhattingh

ASKER

if I run that code from within microsoft excel (VB Script), the http response is a bunch of text that effectively says: "You're using IE and we don't support IE. Please use Firefox"

The problem is, I don't know what module to use (instead of MSXML2) that would allow me to ask for httpResponse data and not be implicitly using a microsoft browser object....
>>...a bunch of text that effectively says...

What does the text say, exactly?
It will be a while before I get to the windows PC again to get exact data, but it should be enough to describe this way:

I get exactly the same data as I would if I attempted to use IE with the url I provide in the script. In other words, I get the same as if I would right-click in IE and "view source".

I know in Firefox, these three things are invalid:

XMLHTTPRequest
http.Open
False

They should be:

XMLHttpRequest
http.open
false
Avatar of hielo
The server you are contacting "thinks" that you are using IE to retrieve the data. You need to specify your own user-agent value.
Try:
Dim http As New MSXML.XMLHTTPRequest
http.Open "post", "http://www.advfn.com/blah,blah,blah", False, "Username", "Password"
http.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5"
http.send
Str = http.responseText

If he specifies >MSXML.XMLHTTPRequest<, then he *is* using IE.
Thanks for the suggestion. I tried it, but get the same results...

I was thinking: What if I get the "variable names" for the username/password that usually is supplied in the login page.. then "somehow" send those credentials as cookies WITH the above httpRequest...

Is this "pie in the sky" idea even feasible?
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fantastic.