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.
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
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....
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?
What does the text say, exactly?
ASKER
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 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
XMLHTTPRequest
http.Open
False
They should be:
XMLHttpRequest
http.open
false
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
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.
ASKER
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Fantastic.
I'm not sure what you are asking, I guess...