Global $oHTTP = ObjCreate('WinHttp.WinHttpRequest.5.1');
$sServer = "http://devbuilds.kaspersky-labs.com/devbuilds/AVPTool/avptool11/"
$iPort = 80
If _HTTPServerIsOnline($sServer, $iPort) Then
MsgBox(64, "Проверка сервера", "Сервер [" & $sServer & "] on-line.",2)
$oHTTP.Open($sServer); МЫ "открываем" страничку с нужными нам результатами.
$oHTTP.Send('')
$oHTTP.WaitForResponse
$Response = $oHTTP.ResponseText ; получили HTML странички.
$a = StringRegExp($Response,'<a href="(.+?\.exe)">',3); Регулярное выражение, что бы получить названия файлов.
$File = $a[UBound($a)-1] ; Последнее название файла.
InetGet('http://devbuilds.kaspersky-labs.com/devbuilds/AVPTool/avptool11/'&$File,$File); Скачиваем файл в директорию со скриптом. Или вами указанную.
Else
MsgBox(48, "Проверка сервера", "Сервер [" & $sServer & "] НЕ on-line.")
EndIf
Func _HTTPServerIsOnline($sServer, $iPort = 80)
TCPStartup()
$sServer = StringRegExpReplace($sServer, '(?i)^[a-z]{3,6}://', '')
Local $sName_To_IP = TCPNameToIP($sServer)
Local $iSocket = TCPConnect($sName_To_IP, $iPort)
If $iSocket = -1 Then
TCPCloseSocket($iSocket)
Return SetError(1, 0, "")
EndIf
Local $sCommand = "HEAD / HTTP/1.1" & @CRLF
$sCommand &= "Host: " & $sServer & @CRLF
$sCommand &= "User-Agent: AutoIt/" & @AutoItVersion & " (Windows; U; Windows NT 5.1; en-US; rv:1.8.1)" & @CRLF
$sCommand &= "Referer: " & $sServer & @CRLF
$sCommand &= "Connection: close" & @CRLF & @CRLF
Local $iBytesSent = TCPSend($iSocket, $sCommand)
If $iBytesSent = 0 Then Return SetError(2, @error, 0)
Local $sRecv = "", $sCurrentRecv
While 1
$sCurrentRecv = TCPRecv($iSocket, 16)
If @error <> 0 Then
ExitLoop
EndIf
If $sCurrentRecv <> "" Then
$sRecv &= $sCurrentRecv
EndIf
WEnd
TCPCloseSocket($iSocket)
TCPShutdown()
Return StringRegExp($sRecv, "(?i)HTTP/\d.\d (200|30[1-2])") = 1
EndFunc