簡體   English   中英

在Excel中使用Winhttp從URL下載xml文件-CHARSET = UTF-8

[英]download xml file from url using winhttp in excel - CHARSET=UTF-8

我正在嘗試自動從URL下載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

輸出字符串

在此處輸入圖片說明

請參閱Content-Encoding: gzip 您需要使用gzip解壓縮主體,或者使用將為您完成工作的客戶端庫。

不過,作為旁注,如果服務器在您未發送Accept-Encoding: gzip向您發送了gzip壓縮響應,則可能出了點問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM