我的 VBA 代码发送除 Cookie 信息之外的所有标头。
Dim oXMLHttpRequest As Object
Set oXMLHttpRequest = CreateObject("Microsoft.XmlHttp")
oXMLHttpRequest.setRequestHeader "Accept", "text/html, application/xhtml+xml, */*"
oXMLHttpRequest.setRequestHeader "Accept-Language", "ko-KR"
oXMLHttpRequest.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
oXMLHttpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHttpRequest.setRequestHeader "Accept-Encoding", "gzip, deflate"
oXMLHttpRequest.setRequestHeader "Connection", "Keep-Alive"
oXMLHttpRequest.setRequestHeader "DNT", "1"
oXMLHttpRequest.setRequestHeader "Cookie", "xxx=yyy"
oXMLHttpRequest.send[enter image description here][1]
正如您在下面的捕获链接中看到的,Cookie: xxx=yyy 丢失了。
我没有任何线索。请帮我。
谢谢。
提琴手捕获:
有一个rumour http://objectmix.com/xml-soap/86831-excel-vba-xmthttp-cookies.html在 Google 上,您必须在此处使用 WinHTTP 对象,而不是 MSXML2。例如。:
Option Explicit
Sub Test()
Dim objRequest As Object
Dim strResponse As String
Dim blnAsync As Boolean
Set objRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
blnAsync = True
With objRequest
.Open "POST", "http://www.comparity.net/perl/form.pl", blnAsync
.setRequestHeader "Cookie", "timtam=penguin"
.send
.WaitForResponse
strResponse = .responseText
Debug.Print strResponse
Debug.Print .Status
End With
End Sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)