我正在尝试从网址自动下载xml文件。即使经过多次尝试,我也无法想到可能的解决方案,并想知道是否有人可以通过查看输出和响应标题来帮助我,url是敏感的。
使用excel我正在通过winhttp向url和response.body做一个http请求,它给出了我无法弄清楚如何读取并从中获取数据的输出。
请求标题
url = "https://***sensitive***.com/psc/FS91PRD/EMPLOYEE/ERP/q/?ICQryName=W_GL_INTL_JNLS&ICDummy=1186278907"
With http
.Open "POST", url, False
.setRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
.setRequestHeader "Referer", "https://***sensitive***_GL_INTL_JNLS&ICDummy=1186278907"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.setRequestHeader "Accept-Encoding", "gzip, deflate"
.setRequestHeader "Host", "***sensitive****"
'.setRequestHeader "Content-Length", "360"
.setRequestHeader "Connection", "keep-alive"
.setRequestHeader "cache-Control", "no-cache"
.setRequestHeader "Cookie", cookie2
.send postData
.waitForResponse
End With
End If
Debug.Print http.getAllResponseHeaders
回复标题
Date: Sun, 24 May 2015 14:03:13 GMT
Content-Length: 10673
Content-Type: text/html; CHARSET=UTF-8
Content-Encoding: gzip
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Set-Cookie: PS_TOKENEXPIRE=24_May_2015_14:03:13_GMT;
IgnorePortalRegisteredURL: 1
PortalRegisteredURL: https://***sensitive***.com/
UsesPortalRelativeURL: true
X-Powered-By: Servlet/2.5 JSP/2.1
输出字符串
答案 0 :(得分:3)
请参阅Content-Encoding: gzip
?您需要使用gzip解压缩正文,或使用可以为您执行此操作的客户端库。
但是,作为旁注,如果服务器在您未发送Accept-Encoding: gzip
时向您发送了压缩响应,那么它就会出现问题。