|
我在用Fiddler进行单步模拟的时候都是成功的的,可是同样的 请求头RequestHeader 设置,为什么到VBA里面就不管用了呢?
下面是我在Fiddler中设置以及执行结果,是有ResponseHeader返回的:
请求:
GET https://www.portnet.com/login HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; Trident/7.0; rv:11.0) like Gecko
UA-CPU: AMD64
Accept-Encoding: gzip, deflate
Host: www.portnet.com
Connection: Keep-Alive
Cookie: fvv=; lastSelectedProductIndex=1; loginTime=1531201855941
返回:
HTTP/1.1 307 Temporary Redirect
Content-Length: 0
X-Frame-Options: ALLOW-FROM http://ip.zscaler.com/
Content-Security-Policy: frame-ancestors http://ip.zscaler.com https://ip.zscaler.com;
Location: https://gateway.zscaler.net:443/ ... SW2755D51LD5176VPTP
Content-Type: text/html
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"
Set-Cookie: _sm_au_d=1;path=/;domain=.portnet.com
-----------------------------------------------------------
我在VBA中是如下
Sub ttt()
Dim web As New WinHttpRequest
With web
.Open "GET", "https://www.portnet.com/login", False
.SetRequestHeader "Accept", "text/html, application/xhtml+xml, */*"
.SetRequestHeader "Accept-Language", "en-US"
.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; Trident/7.0; rv:11.0) like Gecko"
.SetRequestHeader "UA-CPU", "AMD64"
.SetRequestHeader "Accept-Encoding", "gzip, deflate"
.SetRequestHeader "Host", "www.portnet.com"
.SetRequestHeader "Connection", "Keep-Alive"
.SetRequestHeader "Cookie", "fvv=; lastSelectedProductIndex=1; loginTime=1531201855941"
.Option(6) = 0
.Option(4) = 13056
.Send '------>执行到这句就卡住了,最终会弹出一个对话框,对话框内容见代码下面
End With
End Sub
弹出的错误对话框内容:
Run-tim error '-2147012894 (80072ee2)':
Automation error
不知道什么原因,但是类似的代码在访问其他网站都可以阿,使网站做了限制吗?如果限制了为什么Fiddler就有内容返回呢?
|
|