Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
Excel VBA, XMTHTTP & Cookies
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Mark Simon, post: 9220783"] (Sorry about cross-posting; I'm not sure which group is the best one for this question.) I need to get data into Excel from a web site which requires some sort of authentication. As far as I can tell, the authentication is in the form of a cookie or two. I have successfully extracted data from websites using VBA and the XMLHTTP object, and even from this site in the case where authentication is not required. However, I cannot seem to send cookies from VBA. I have a sample procedure which tests my coding against a test site which displays form data and cookies: Sub test() Dim x As New XMLHTTP Dim t As String x.Open "get", "[URL]http://www.comparity.net/perl/form.pl[/URL]", False x.setRequestHeader "Cookie", "one=foo;two=bar;" x.setRequestHeader "Cookie", "one=foo;two=bar;" x.send t = x.responseText WriteTextFile "c:\test.html", t Debug.Print x.Status Debug.Print t End Sub The repeated setRequestHeader code is to handle a bug, as listed in the kb article: [URL]http://support.microsoft.com/kb/290899[/URL] though I'm not 100% sure that it applies in this case. The WriteTextFile procedure is used so I can read the response, and is listed below: Sub WriteTextFile(FileName, Text) Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim fs, f Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.OpenTextFile(FileName, ForWriting, -2) f.Write Text f.Close End Sub So, does anybody have any idea why my cookies are not being sent, or how I can send them some other way? Thanks, Mark [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
Excel VBA, XMTHTTP & Cookies
Top