回复 1# kxing Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Option(0) = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)"
$oHTTP.Option(4) = 13056 ;忽略错误标志
$oHTTP.Option(6) = False ;禁用重定向
$oHTTP.SetTimeouts(30000, 30000, 30000, 30000)
Local $sUrl, $sBody
$sUrl = "http://www.xdowns.com/soft/xdowns2009.asp?softid=60680&downid=49&id=63529"
$oHTTP.Open('GET', $sUrl, True)
$oHTTP.Send()
$sBody = waitResponse()
ConsoleWrite($sBody & @CRLF)
$sUrl = $oHTTP.getResponseHeader("Location")
Local $sName = StringTrimLeft($sUrl, StringInStr($sUrl, "/", 0, -1))
MsgBox(0, 0, "下载链:" & $sUrl & @CRLF & @CRLF & "文件名:" & $sName)
Func waitResponse($i_Time = -1, $b_Bin = False)
Local $s_Header = ""
If Not $oHTTP.WaitForResponse($i_Time) Then
$oHTTP.Abort()
Return SetError(1, 0, "")
EndIf
If $b_Bin Then Return $oHTTP.responseBody
$s_Header = $oHTTP.GetResponseHeader("Content-Type")
If StringInStr($s_Header, "gb2312") Or StringInStr($s_Header, "gbk") Then
Return BinaryToString($oHTTP.responseBody, 1)
Else
Return BinaryToString($oHTTP.responseBody, 4)
EndIf
EndFunc ;==>waitResponse
|