[已解决]如何让WinHttp组件获取的内容和IE操作获取的相同?
本帖最后由 帆船 于 2017-3-18 16:53 编辑访问 http://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=975bd6c2-d69f-48f9-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操作获取的相同? 本帖最后由 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)
回复 2# nmgwddj
啊,非常感谢,又学习了一招!
页:
[1]