gpt4 book ai didi

VBA Microsoft.XMLHTTP setRequestHeader 不发送 cookie

转载 作者:可可西里 更新时间:2023-11-01 16:09:19 30 4
gpt4 key购买 nike

我的 VBA 代码发送除 Cookie 信息之外的所有 header 。

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 丢失了。我没有任何线索。请帮我。谢谢。

Fiddler 捕获:

Fiddler capture

最佳答案

有一个 rumour在 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

关于VBA Microsoft.XMLHTTP setRequestHeader 不发送 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38306825/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com