目前我正在使用 WinHttpRequest 从 web 应用程序中提取数据。我设法成功地执行了各种任务,但是我偶然发现了奇怪的问题。.ResponseText 中缺少一些数据。我已经手动完成了任务,responsebody 是:
<?xml version="1.0" encoding="UTF-8"?>
<mxRoot><rows><r ra="t" o="20336.41905.48904.52482" p="" id="0,0" level="0" filter="false" t="1515418285649" r="" d="" hc="">
<c a="91664964" i="images/iconSmallPart.png">91664964</c><c a="001">001</c> :ConfidentialInformations: </rows>
当我对 VBA 做同样的事情时,答案会更短:
<?xml version="1.0" encoding="UTF-8"?>
<mxRoot><rows><r ra="t" o="20336.41905.39945.55654" p="" id="0,0" level="0" filter="false" /></rows>
就像我从响应中遗漏了一些深度。下面的代码我正在使用。
Set MyRequest = CreateObject("WinHTTP.WinHTTPrequest.5.1")
MyRequest.Open "POST", URL
MyRequest.SetRequestHeader "Host", "plmprod.pg.com"
MyRequest.Option(WinHttpRequestOption_EnableRedirects) = False
MyRequest.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:57.0) Gecko/20100101 Firefox/57.0"
MyRequest.SetRequestHeader "Accept", "*/*"
MyRequest.SetRequestHeader "Accept-Language", "pl,en-US;q=0.7,en;q=0.3"
MyRequest.SetRequestHeader "Accept-Encoding", "gzip, deflate, br"
MyRequest.SetRequestHeader "Referer", "RefererURL"
MyRequest.SetRequestHeader "Content-Type", "undefined"
MyRequest.SetRequestHeader "charset", "UTF-8"
MyRequest.SetRequestHeader "csrfTokenName", "ENO_CSRF_TOKEN"
MyRequest.SetRequestHeader "ENO_CSRF_TOKEN", CSRFTOKEN
MyRequest.SetRequestHeader "Cookie", "testcookie=1; " & JSESSION & "; " & SERVERID
MyRequest.SetRequestHeader "Connection", "keep-alive"
MyRequest.SetRequestHeader "Content-Length", "0"
MyRequest.Send
MyRequest.WaitForResponse
Debug.Print MyRequest.ResponseText
有谁知道问题是什么?即使我找到了类似的主题,也没有明确的答案。