简体   繁体   English

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

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

I am trying to automate downloading of xml file from a url. 我正在尝试自动从URL下载xml文件。 Even after multiple attempts I couldn't think of possible solution to this and wonder if anyone could help me by just looking at the output and response header, url being sensitive. 即使经过多次尝试,我也无法想到可能的解决方案,并且想知道是否有人可以通过查看输出和响应标头(URL敏感)来帮助我。

Using the excel I am doing a http request via winhttp to the url and in the response.body its giving the ouput which I can't figure out how to read and get the data out of it. 使用Excel,我通过winhttp到URL和response.body发出了一个http请求,给出了输出,我无法弄清楚如何读取数据并从中获取数据。

Request header 请求标头

   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

Response header 响应头

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

Output String 输出字符串

在此处输入图片说明

See the Content-Encoding: gzip ? 请参阅Content-Encoding: gzip You need to decompress the body using gzip, or use a client library that will do it for you. 您需要使用gzip解压缩主体,或者使用将为您完成工作的客户端库。

Just as a side note, though, if the server sent you a gzipped response when you didn't send Accept-Encoding: gzip , there's something wrong with it. 不过,作为旁注,如果服务器在您未发送Accept-Encoding: gzip向您发送了gzip压缩响应,则可能出了点问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 内容类型'text / xml; charset = utf-8'不是预期的类型'application / soap + xml; 字符集= UTF-8' - content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8' 在Mac上下载的文本文件中的字符集和UTF-8 - Charset and UTF-8 in a downloaded text file on a Mac PHP查询不使用UTF-8字符集 - php query not using UTF-8 charset 使用字符集utf-8时出错 - Error when using charset utf-8 UTF-8 从 MySQL 到 PHP 的字符集问题 - UTF-8 charset issues from MySQL in PHP 如何编写csv文件并在字符集UTF-8中的MS.Excel中打开 - How to write csv file and open in MS.Excel in charset UTF-8 CodeIgniter 字符集为 UTF-8 - CodeIgniter charset to UTF-8 歌剧字符集UTF-8 - Opera charset UTF-8 由于内容类型为'text / xml ;,因此无法处理该消息; charset = utf-8'不是预期的类型'application / soap + xml; charset = utf-8' - Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8' 无法处理消息,因为内容类型 'application/xml;charset=“utf-8”' 不是预期的类型 'text/xml; 字符集=utf-8' - Cannot process the message because the content type 'application/xml;charset=“utf-8”' was not the expected type 'text/xml; charset=utf-8'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM