我正在尝试从网站获取信息,为此我创建了以下VBA代码。但是,请求将始终超时。我犯了某种根本性的错误吗?
现在我正在模仿我的浏览器发送的请求,也许这就是问题的根源。我已经看到other posts这样做了,但似乎有效。
代码:
Sub fill()
Dim w As New WinHttpRequest
w.SetTimeouts 5000, 5000, 5000, 5000
w.Open "POST", "http://www.vti.net.au/calculator"
w.SetRequestHeader "Host", "www.vti.net.au"
w.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0"
w.SetRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
w.SetRequestHeader "Accept-Language", "en-US,en;q=0.5"
w.SetRequestHeader "Accept-Encoding", "gzip, deflate"
w.SetRequestHeader "Referer", "http://www.vti.net.au/calculator"
w.SetRequestHeader "Cookie", "SESS85bf6b43b33c734cba757f15a25cc79e=7521a51d45d3609955bf90d18f8d0f90; has_js=1; _ga=GA1.3.2146414506.1410196274"
w.SetRequestHeader "Connection", "keep-alive"
w.Send "Length=330&Connectors=4&Splices=4&Cord=1&submit=Calculate"
MsgBox "test"
End Sub
请求信息: