找回密码
 加入
搜索
查看: 1703|回复: 2

[网络通信] [已解决]如何让WinHttp组件获取的内容和IE操作获取的相同?

[复制链接]
发表于 2017-3-18 14:00:08 | 显示全部楼层 |阅读模式
本帖最后由 帆船 于 2017-3-18 16:53 编辑

访问 http://www.catalog.update.micros ... 9-bab5-b701e4a44294 通过如下代码产生的两个网页文件,
#include <IE.au3>
$sUrl = "http://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=975bd6c2-d69f-48f9-bab5-b701e4a44294"
$WinHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")
$WinHttp.Open('Get', $sUrl, False)
$WinHttp.Send()
$sText = $WinHttp.ResponseText
$hFile = FileOpen("WinHttp.html", 2)
FileWrite($hFile, $sText)
FileClose($hFile)
$oIE = _IECreate($sUrl, 0, 0)
_IELoadWait($oIE)
Sleep(500)
$sText = _IEDocReadHTML($oIE)
_IEQuit($oIE)
$hFile = FileOpen("IEDocRead.html", 2)
FileWrite($hFile, $sText)
FileClose($hFile)
通过WinHttp组件获取的内容文字为英文,

通过IE操作获取的内容文字为中文。
而IE操作一般是不稳定的,不想采用IE的方法,如何让WinHttp组件获取的内容和IE操作获取的相同?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2017-3-18 16:06:38 | 显示全部楼层
本帖最后由 nmgwddj 于 2017-3-18 16:07 编辑


#include <IE.au3>
$sUrl = "http://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=975bd6c2-d69f-48f9-bab5-b701e4a44294"
$WinHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")
$WinHttp.Open('Get', $sUrl, False)
$WinHttp.setRequestHeader("Accept-Language", "zh-CN")
$WinHttp.Send()
$sText = $WinHttp.ResponseText
$hFile = FileOpen("WinHttp.html", 2)
FileWrite($hFile, $sText)
FileClose($hFile)


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2017-3-18 16:53:58 | 显示全部楼层
回复 2# nmgwddj
啊,非常感谢,又学习了一招!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-18 23:02 , Processed in 0.079827 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表