Dynamische URL runterladen - geht doch nicht

  • Hallo!

    Ich will bei Uploaded eine Datei runterladen per AutoIT. Den Link bekomme ich schon, allerdings kann ich nichts runterladen.
    Der Link ist dynamisch (mit einem ? drin), z.B. "http://s14b0-cb.uploaded.to/dl?id=218133a4f1cf5d1132d5f5316fdbe7ee"

    Wie kann ich die Datei dann runterladen?

    2 Mal editiert, zuletzt von Taek (1. Oktober 2008 um 14:49)

  • jDownloader ist darauf spezialisiert, einfach URL in die Zwischenablage, dann auf das grüne PLUS klichen und hinzufügen. Das Programm filtert selbstandig den Link aus der URL.
    Sonst wirds schwierig, weil da immer Captchas und Wartezeiten sind, außerdem kann von Uploaded.to immer nur eine Datei gleichzeitig downgeloadet werden.

    Ich werde's aber auch mal versuchen mit Autoit. _IELoadWait muss ja irgendwie gehen.

  • JD oder Cryptload kann ich auch ;)

    Aber mit AutoIT hab ichs noch nicht geschafft. Auch in Firefox zeigt er mir als Quell-Url nur den einen an.

    EDIT: Mein bisheriger Code:

    Spoiler anzeigen
    [autoit]

    #include <IE.au3>
    #include <INET.au3>
    #include <String.au3>

    [/autoit] [autoit][/autoit] [autoit]

    _Download("http://uploaded.to/?id=4dh2ph")

    [/autoit] [autoit][/autoit] [autoit]

    Func _Download($sURL)
    $oIE = _IECreate($sURL,0,1,1,0)
    $link = _StringBetween(_IEDocReadHTML($oIE),'download_form action=',' method=post')
    Sleep(10*1000)
    ;InetGet($link[0],@SCriptdir&"\test.datei",1,1)
    MsgBox(0,"",_INetGetSource($link[0]))
    EndFunc ;==>Download

    [/autoit]

    Einmal editiert, zuletzt von Taek (19. September 2008 um 12:04)

  • Ich hab grad mit dem RapidShare Donwloader rumgespielt. So in etwa geht der Download schon. KA, ob der Tooltip stimmt ;), Hab den Freetraffic aufgebraucht :(

    Spoiler anzeigen
    [autoit]

    #include <String.au3>
    #include <Inet.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $bDownloadActive = False
    UploadedToGetFile("http://uploaded.to/?id=4dh2ph")
    ;~ $thanks1 = "http://rapidshare.com/files/140030178/thanks4.dl"
    ;~ Download($thanks1)

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: Download
    ; Description:: Download a file from UploadedTo
    ; Parameter(s): $sURL: Download Link
    ; Requirement(s): _INetGetSourcePost()
    ; Return Value(s): True on Succes
    ; : False (0) on Failed
    ; : @error codes:
    ; : 1 - Couldn't connect to rapidshare server on port 80
    ; : 2 - Error by sending string
    ; : 6 - Helpful for abort function: If $bDownloadActive = false while downloading
    ; : 7 - Not 200 OK received, Return: $sRecv
    ;
    ; Author(s): GtaSpider (modified by Taek)
    ;
    ;===============================================================================
    Func UploadedToGetFile($sURL)
    Local $sSendString, $hSocket, $sRecv, $iExt, $aRegEx, $sRet
    TCPStartup()
    Local $source2 = _INetGetSourceEx($sURL)
    ConsoleWrite($source2[0] & @CRLF)
    Local $donwloadLink = _StringBetween($source2[1], '<form name="download_form" method="post" action="', '">')
    Local $FileName = _StringBetween($source2[1], "<title>"," ... at uploaded.to")
    ;Sleep(31*1000)

    [/autoit] [autoit][/autoit] [autoit]

    $split = StringSplit(StringTrimLeft($donwloadLink[0],StringInStr($donwloadLink[0],"//")+1),"/")
    Local $server = $split[1]
    ;~ Local $sURL = $donwloadLink[0]
    MsgBox(0, '', $server)
    ;~ Return
    If Not ($server = "") Then
    $hSocket = TCPConnect(TCPNameToIP($server), 80)
    If @error Then Return SetError(1, @error, 0)
    $sGet = StringRegExpReplace($donwloadLink[0],"\A.*?"&$server,"",1)
    MsgBox(0, '', $sGet)

    [/autoit] [autoit][/autoit] [autoit]

    $sSendString = "POST " & $sGet & " HTTP/1.1" & @CRLF & _
    "Host: "& $server & @CRLF & _
    "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1" & @CRLF & _
    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & @CRLF & _
    "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" & @CRLF & _
    "" & _ ;~ "Accept-Encoding: gzip,deflate" & @CRLF & _ ; Wir können nicht dekodieren !
    "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @CRLF & _
    "Keep-Alive: 300" & @CRLF & _
    "Connection: keep-alive" & @CRLF & _
    "Referer: " & $sURL & @CRLF & _
    "Content-Length: " & StringLen("download_submit=Download;") & @CRLF & _
    "Connection: keep-alive" & @CRLF & @CRLF & "download_submit=Download;"
    MsgBox(0,"",$sSendString)
    _HTTPSend($sSendString, $hSocket)
    If @error Then SetError(2, 0, 0)
    $bDownloadActive = True
    $sRecv = _HTTPRecv($hSocket, 50, 0,@ScriptDir & "\" & $FileName[0] , 1)
    $error = @error
    If $error = 1 Then
    TCPCloseSocket($hSocket)
    $hSocket = TCPConnect(TCPNameToIP($server), 80)
    $URL = StringRegExp($sRecv,"Location:\h*(.*)",3)
    $sSendString = StringReplace($sSendString,"POST " &$sGet,"GET " &$URL[0])
    _HTTPSend($sSendString, $hSocket)
    If @error Then SetError(2, 0, 0)
    $bDownloadActive = True
    $sRecv = _HTTPRecv($hSocket, 50, 0,@ScriptDir & "\" & $FileName[0] , 1)
    $error = @error
    EndIf
    MsgBox(0, '', $sRecv)
    If $error = 4 Then Return SetError(6, 0, 0)
    Return True
    EndIf
    TCPShutdown()
    EndFunc ;==> Download

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;HTTP Send
    ;by GtaSpider
    Func _HTTPSend($sSendString, $hSocket, $iBuffersize = 2904)
    Local $sBuffer = $sSendString, $iProz
    If $iBuffersize < 1024 Then $iBuffersize = 1024
    While StringLen($sBuffer)
    $iSend = 0
    If $iBuffersize >= StringLen($sBuffer) Then $iBuffersize = StringLen($sBuffer) + 2
    While $iSend < $iBuffersize
    $iSend += TCPSend($hSocket, StringLeft($sBuffer, $iBuffersize))
    If @error Then ExitLoop Beep() + 1
    WEnd
    $sBuffer = StringTrimLeft($sBuffer, $iBuffersize)
    $iProz = Round(100 - (100 * StringLen($sBuffer) / StringLen($sSendString)))
    WEnd
    EndFunc ;==>_HTTPSend

    [/autoit] [autoit][/autoit] [autoit]

    ;HTML Recv
    ;by GtaSpider
    Func _HTTPRecv($hSocket, $iSleep = 50, $iTimeOut = 20000, $sDwn = False, $iForceBinary = 0, $iBuffersize = 1024)
    Local $sRecv, $sRet, $iErr = 0, $hTi, $hFiOp, $sFirstRecv, $iLen = 0, $iFirst = True
    If $iTimeOut > 0 Then $hTi = TimerInit()
    If $sDwn Then $hFiOp = FileOpen($sDwn, 17)
    While 1
    If $iTimeOut > 0 And TimerDiff($hTi) > $iTimeOut Then ExitLoop
    $sRecv = TCPRecv($hSocket, $iBuffersize, $iForceBinary)
    $iErr = @error
    If $iErr Then ExitLoop
    If $sDwn And (Not $bDownloadActive) Then ExitLoop
    While StringLen($sRecv)
    If $iForceBinary Then $sRecv = BinaryToString($sRecv)
    If $iFirst Then
    If Not StringInStr($sRecv, "HTTP/1.1 200 OK") Then
    TCPCloseSocket($hSocket)
    If $sDwn Then FileClose($hFiOp)
    Return SetError(1, 1, "ERR:" & $sRecv)
    EndIf
    $Filelen = StringRegExp($sRecv,"(?i)Content-Length:\h(.*)",3)
    If Not @error Then $Filelen = $Filelen[0]
    $sFirstRecv = $sRecv
    If $sDwn Then $sRecv = StringTrimLeft($sRecv, StringInStr($sRecv, @CRLF & @CRLF)+4)
    $iFirst = False
    EndIf
    If $sDwn Then
    $iLen += StringLen($sRecv)
    ToolTip($iLen/$Filelen*100)
    FileWrite($hFiOp, $sRecv)
    EndIf
    If Not $sDwn Then $sRet &= $sRecv
    $sRecv = TCPRecv($hSocket, $iBuffersize, $iForceBinary)
    $iErr = @error
    If $iErr Then ExitLoop 2
    If $iTimeOut > 0 And TimerDiff($hTi) > $iTimeOut Then ExitLoop 2
    If $sDwn And (Not $bDownloadActive) Then ExitLoop 2
    WEnd
    Sleep($iSleep)
    WEnd
    ToolTip("")
    TCPCloseSocket($hSocket)
    If $sDwn Then FileClose($hFiOp)
    If $iForceBinary Then $sRet = "0x" & StringReplace($sRet, "0x", "")
    If $iTimeOut > 0 And TimerDiff($hTi) > $iTimeOut Then Return SetError(2, 0, "Timeout")
    If $iErr Then Return SetError(3, $iErr, $sRet)
    If Not $bDownloadActive Then Return SetError(4, 0, 0)
    Return $sRet
    EndFunc ;==>_HTTPRecv

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _INetGetSourcePost()
    ; Description: Gets the source from an URL without writing a temp file and you can send a Post.
    ; Parameter(s): $sURL = The URL of the site.
    ; $sPost = The Post to send
    ; Requirement(s): -
    ; Return Value(s): On Success - Return a array with $aReturn[0] = Backheader and $aReturn[1] = Sourcecode
    ; On Failure - 0 and sets @ERROR
    ; @error = 1: Post or URL is nothing
    ; @error = 2: Error by RegularExpression
    ; @error = 3: $sHost or $sHttp1 is nothing
    ; @error = 4: Can not get IP of Host
    ; @error = 5: Can not connect to host
    ; @error = 6: Nothing can be send
    ; @error = 7: Connection abborted while receiving
    ; Author(s): GtaSpider
    ;
    ;===============================================================================
    Func _INetGetSourcePost($sURL, $sPost)
    Local $iSocket, $sHeader, $sRecv, $iIP, $sHost, $aRegExp, $sHttp1,$iErr,$iSend,$aReturn[2]

    If $sURL = '' Or $sPost = '' Then Return SetError(1, 0, 0)

    If StringLeft($sURL, 7) <> 'http://' And StringLeft($sURL, 8) <> 'https://' Then $sURL = "http://" & $sURL
    If StringRight($sURL, 1) <> "/" Then $sURL &= "/"

    $aRegExp = StringRegExp($sURL, "http?://(.*?)/", 3)
    If @error Then Return SetError(2, 0, 0)

    $sHost = $aRegExp[0]
    If $sHost = '' Then Return SetError(3, 0, 0)

    $sHttp1 = StringTrimLeft($sURL,StringInStr($sURL,"/",-1,3)-1)
    If $sHttp1 = '' Then Return SetError(3, 0, 0)


    $sHeader = "POST " & $sHttp1 & " HTTP/1.1" & @CRLF & _
    "Host: " & $sHost & @CRLF & _
    "User-Agent: AutoIt v3" & @CRLF & _
    "Content-Length: " & StringLen($sPost) & @CRLF & @CRLF & $sPost


    TCPStartup() ;If not already done
    $iIP = TCPNameToIP($sHost)
    If $iIP = '' Or StringInStr($iIP, ".") = 0 Then Return SetError(4, 0, 0)
    $iSocket = TCPConnect($iIP, 80)
    If @error Or $iSocket < 0 Then Return SetError(5, 0, 0)

    $iSend = TCPSend($iSocket, $sHeader)
    If @error Or $iSend < 1 Then Return SetError(6, 0, 0)


    While 1
    $sRecv = TCPRecv($iSocket, 1024)
    $iErr = @error
    If $sRecv <> '' Then
    While 1
    $sRecv &= TCPRecv($iSocket, 1024)
    If @error Then ExitLoop 2
    WEnd
    EndIf
    If $iErr Then Return SetError(7,0,0)
    WEnd
    TCPCloseSocket($iSocket)
    TCPShutdown()
    $aReturn[0] = StringLeft($sRecv,StringInStr($sRecv,@CRLF&@CRLF)-1)
    $aReturn[1] = StringTrimLeft($sRecv,StringLen($aReturn[0])+4)
    Return $aReturn
    EndFunc ;==>_INetGetSourcePost

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _INetGetSourceEx()
    ; Description: Gets the source from an URL without writing a temp file and you can send a Post.
    ; Also reads chunked Data.
    ; Parameter(s): $sURL = The URL of the site.
    ; $sPost = The Post to send
    ; Requirement(s): -
    ; Return Value(s): On Success - Return a array with $aReturn[0] = Backheader and $aReturn[1] = Sourcecode
    ; On Failure - 0 and sets @ERROR
    ; @error = 1: Post or URL is nothing
    ; @error = 2: Error by RegularExpression
    ; @error = 3: $sHost or $sHttp1 is nothing
    ; @error = 4: Can not get IP of Host
    ; @error = 5: Can not connect to host
    ; @error = 6: Nothing can be send
    ; @error = 7: Connection abborted while receiving
    ; Author(s): GtaSpider, Modified by Prog@ndy
    ;
    ;===============================================================================
    Func _INetGetSourceEx($sURL, $ReturnArray=True)
    Local $iSocket, $sHeader, $sRecv, $iIP, $sHost, $aRegExp, $sHttp1,$iErr,$iSend,$aReturn[2]

    If $sURL = '' Then Return SetError(1, 0, 0)

    If StringLeft($sURL, 7) <> 'http://' And StringLeft($sURL, 8) <> 'https://' Then $sURL = "http://" & $sURL
    ;~ If StringRight($sURL, 1) <> "/" Then $sURL &= "/"

    $aRegExp = StringRegExp($sURL, "http?://(.*?)/", 3)
    If @error Then Return SetError(2, 0, 0)

    $sHost = $aRegExp[0]
    If $sHost = '' Then Return SetError(3, 0, 0)

    $sHttp1 = StringTrimLeft($sURL,StringInStr($sURL,"/",-1,3)-1)
    If $sHttp1 = '' Then Return SetError(3, 0, 0)

    MsgBox(0, '', $sHttp1)
    $sHeader = "GET " & $sHttp1 & " HTTP/1.1" & @CRLF & _
    "Host: " & $sHost & @CRLF & _
    "User-Agent: AutoIt v3" & @CRLF & @CRLF


    TCPStartup() ;If not already done
    $iIP = TCPNameToIP($sHost)
    If $iIP = '' Or StringInStr($iIP, ".") = 0 Then Return SetError(4, 0, 0)
    $iSocket = TCPConnect($iIP, 80)
    If @error Or $iSocket < 0 Then Return SetError(5, 0, 0)

    $iSend = TCPSend($iSocket, $sHeader)
    If @error Or $iSend < 1 Then Return SetError(6, 0, 0)


    While 1
    $sRecv = TCPRecv($iSocket, 1024)
    $iErr = @error
    If $sRecv <> '' Then
    While 1
    $sRecv &= TCPRecv($iSocket, 1024)
    If @error Then ExitLoop 2
    WEnd
    EndIf
    If $iErr Then Return SetError(7,0,0)
    WEnd
    TCPCloseSocket($iSocket)
    TCPShutdown()
    $aReturn[0] = StringLeft($sRecv,StringInStr($sRecv,@CRLF&@CRLF)-1)
    $aReturn[1] = StringTrimLeft($sRecv,StringLen($aReturn[0])+4)
    ; Chunked Handler:
    If StringRegExp($aReturn[0],"(?i)Transfer-Encoding:\h*chunked") Then
    Local $ChunkedRes=$aReturn[1], $NextSize
    $aReturn[1]=""
    While 1
    $NextSize = StringRegExp($ChunkedRes,"\A(\w+)\h*\r\n",3)
    If @error Then ExitLoop
    $NextSize = Dec($NextSize[0])
    If $NextSize = 0 Then ExitLoop
    $ChunkedRes = StringRegExpReplace($ChunkedRes,"\A\w+\h*\r\n","")
    $aReturn[1] &= StringLeft($ChunkedRes,$NextSize)
    $ChunkedRes = StringTrimLeft($ChunkedRes,$NextSize+2)
    WEnd
    EndIf
    ; End Handler
    If Not $ReturnArray Then Return $aReturn[1]
    Return $aReturn
    EndFunc ;==>_INetGetSourcePost

    [/autoit]
  • So in etwa ja. Wie bist du darauf gekommen?

    Die Datei hat allerding 0 Byte. Kann man das nicht ohne _HTTPSend und _HTTPRecv einfach mit INetGet machen?

    Mit dem jetzigen Code bekomme ich nur 66KB runter, liegt das an den Chunks?
    EDIT: 148KB und 99KB mehr geht nicht...

    Spoiler anzeigen
    [autoit]

    #include <IE.au3>
    #include <INET.au3>
    #include <String.au3>

    [/autoit] [autoit][/autoit] [autoit]

    _Download("http://uploaded.to/?id=4dh2ph")

    [/autoit] [autoit][/autoit] [autoit]

    Func _Download($sURL)
    $oIE = _IECreate($sURL,0,1,1,0)
    $link = _StringBetween(_IEDocReadHTML($oIE),'download_form action=',' method=post')
    Sleep(10*1000)
    InetGet($link[0],@SCriptdir&"\test.datei",1,1)
    EndFunc ;==>Download

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _INetGetSourcePost()
    ; Description: Gets the source from an URL without writing a temp file and you can send a Post.
    ; Parameter(s): $sURL = The URL of the site.
    ; $sPost = The Post to send
    ; Requirement(s): -
    ; Return Value(s): On Success - Return a array with $aReturn[0] = Backheader and $aReturn[1] = Sourcecode
    ; On Failure - 0 and sets @ERROR
    ; @error = 1: Post or URL is nothing
    ; @error = 2: Error by RegularExpression
    ; @error = 3: $sHost or $sHttp1 is nothing
    ; @error = 4: Can not get IP of Host
    ; @error = 5: Can not connect to host
    ; @error = 6: Nothing can be send
    ; @error = 7: Connection abborted while receiving
    ; Author(s): GtaSpider
    ;
    ;===============================================================================
    Func _INetGetSourcePost($sURL, $sPost)
    Local $iSocket, $sHeader, $sRecv, $iIP, $sHost, $aRegExp, $sHttp1,$iErr,$iSend,$aReturn[2]
    If $sURL = '' Or $sPost = '' Then Return SetError(1, 0, 0)
    If StringLeft($sURL, 7) <> 'http://' And StringLeft($sURL, 8) <> 'https://' Then $sURL = "http://" & $sURL
    If StringRight($sURL, 1) <> "/" Then $sURL &= "/"
    $aRegExp = StringRegExp($sURL, "http?://(.*?)/", 3)
    If @error Then Return SetError(2, 0, 0)
    $sHost = $aRegExp[0]
    If $sHost = '' Then Return SetError(3, 0, 0)
    $sHttp1 = StringTrimLeft($sURL,StringInStr($sURL,"/",-1,3)-1)
    If $sHttp1 = '' Then Return SetError(3, 0, 0)
    $sHeader = "POST " & $sHttp1 & " HTTP/1.1" & @CRLF & _
    "Host: " & $sHost & @CRLF & _
    "User-Agent: AutoIt v3" & @CRLF & _
    "Content-Length: " & StringLen($sPost) & @CRLF & @CRLF & $sPost
    TCPStartup() ;If not already done
    $iIP = TCPNameToIP($sHost)
    If $iIP = '' Or StringInStr($iIP, ".") = 0 Then Return SetError(4, 0, 0)
    $iSocket = TCPConnect($iIP, 80)
    If @error Or $iSocket < 0 Then Return SetError(5, 0, 0)

    $iSend = TCPSend($iSocket, $sHeader)
    If @error Or $iSend < 1 Then Return SetError(6, 0, 0)
    While 1
    $sRecv = TCPRecv($iSocket, 1024)
    $iErr = @error
    If $sRecv <> '' Then
    While 1
    $sRecv &= TCPRecv($iSocket, 1024)
    If @error Then ExitLoop 2
    WEnd
    EndIf
    If $iErr Then Return SetError(7,0,0)
    WEnd
    TCPCloseSocket($iSocket)
    TCPShutdown()
    $aReturn[0] = StringLeft($sRecv,StringInStr($sRecv,@CRLF&@CRLF)-1)
    $aReturn[1] = StringTrimLeft($sRecv,StringLen($aReturn[0])+4)
    Return $aReturn
    EndFunc ;==>_INetGetSourcePost

    [/autoit]

    Einmal editiert, zuletzt von Taek (19. September 2008 um 15:29)

  • Meine Variante ging bei mir, bi ich das Download-Limit überschritten hab ... Mus jetzt noch ca. 20 Min warten...

  • Gut, meine auch :thumbup:

    EDIT: Anscheinend funktioniert mein Script nicht immer. Deshalb hab ich das von Progandy hergenommen. Kann es vielleicht jemand testen? Bei mir wird immer nur eine 0 KB Datei erstellt.

    Spoiler anzeigen
    [autoit]

    #include <String.au3>
    #include <Inet.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $bDownloadActive = False
    UploadedToGetFile("http://uploaded.to/?id=k6y6fu")

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: Download
    ; Description:: Download a file from UploadedTo
    ; Parameter(s): $sURL: Download Link
    ; Requirement(s): _INetGetSourcePost()
    ; Return Value(s): True on Succes
    ; : False (0) on Failed
    ; : @error codes:
    ; : 1 - Couldn't connect to rapidshare server on port 80
    ; : 2 - Error by sending string
    ; : 6 - Helpful for abort function: If $bDownloadActive = false while downloading
    ; : 7 - Not 200 OK received, Return: $sRecv
    ;
    ; Author(s): GtaSpider (modified by Taek)
    ;
    ;===============================================================================
    Func UploadedToGetFile($sURL)
    Local $sSendString, $hSocket, $sRecv, $iExt, $aRegEx, $sRet
    TCPStartup()
    Local $source2 = _INetGetSourceEx($sURL)
    Local $downloadLink = _StringBetween($source2[1], '<form name="download_form" method="post" action="', '">')
    Local $FileName = _StringBetween($source2[1], "<title>"," ... at uploaded.to")
    $split = StringSplit(StringTrimLeft($downloadLink[0],StringInStr($downloadLink[0],"//")+1),"/")
    Local $server = $split[1]
    If Not ($server = "") Then
    $hSocket = TCPConnect(TCPNameToIP($server), 80)
    If @error Then Return SetError(1, @error, 0)
    $sGet = StringRegExpReplace($downloadLink[0],"\A.*?"&$server,"",1)
    MsgBox(0, '3', $sGet)

    [/autoit] [autoit][/autoit] [autoit]

    $sSendString = "POST " & $sGet & " HTTP/1.1" & @CRLF & _
    "Host: "& $server & @CRLF & _
    "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1" & @CRLF & _
    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & @CRLF & _
    "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" & @CRLF & _
    "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @CRLF & _
    "Keep-Alive: 300" & @CRLF & _
    "Connection: keep-alive" & @CRLF & _
    "Referer: " & $sURL & @CRLF & _
    "Content-Length: " & StringLen("download_submit=Download;") & @CRLF & _
    "Connection: keep-alive" & @CRLF & @CRLF & "download_submit=Download;"
    _HTTPSend($sSendString, $hSocket)
    If @error Then SetError(2, 0, 0)
    $bDownloadActive = True
    $sRecv = _HTTPRecv($hSocket, 50, 0,@ScriptDir & "\" & $FileName[0] , 1)
    $error = @error
    If $error = 1 Then
    TCPCloseSocket($hSocket)
    $hSocket = TCPConnect(TCPNameToIP($server), 80)
    $URL = StringRegExp($sRecv,"Location:\h*(.*)",3)
    $sSendString = StringReplace($sSendString,"POST " &$sGet,"GET " &$URL[0])
    _HTTPSend($sSendString, $hSocket)
    If @error Then SetError(2, 0, 0)
    $bDownloadActive = True
    $sRecv = _HTTPRecv($hSocket, 50, 0,@ScriptDir & "\" & $FileName[0] , 1)
    $error = @error
    EndIf
    If $error = 4 Then Return SetError(6, 0, 0)
    Return True
    EndIf
    TCPShutdown()
    EndFunc ;==> Download

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;HTTP Send
    ;by GtaSpider
    Func _HTTPSend($sSendString, $hSocket, $iBuffersize = 2904)
    Local $sBuffer = $sSendString, $iProz
    If $iBuffersize < 1024 Then $iBuffersize = 1024
    While StringLen($sBuffer)
    $iSend = 0
    If $iBuffersize >= StringLen($sBuffer) Then $iBuffersize = StringLen($sBuffer) + 2
    While $iSend < $iBuffersize
    $iSend += TCPSend($hSocket, StringLeft($sBuffer, $iBuffersize))
    If @error Then ExitLoop Beep() + 1
    WEnd
    $sBuffer = StringTrimLeft($sBuffer, $iBuffersize)
    $iProz = Round(100 - (100 * StringLen($sBuffer) / StringLen($sSendString)))
    WEnd
    EndFunc ;==>_HTTPSend

    [/autoit] [autoit][/autoit] [autoit]

    ;HTML Recv
    ;by GtaSpider
    Func _HTTPRecv($hSocket, $iSleep = 50, $iTimeOut = 20000, $sDwn = False, $iForceBinary = 0, $iBuffersize = 1024)
    Local $sRecv, $sRet, $iErr = 0, $hTi, $hFiOp, $sFirstRecv, $iLen = 0, $iFirst = True
    If $iTimeOut > 0 Then $hTi = TimerInit()
    If $sDwn Then $hFiOp = FileOpen($sDwn, 17)
    While 1
    If $iTimeOut > 0 And TimerDiff($hTi) > $iTimeOut Then ExitLoop
    $sRecv = TCPRecv($hSocket, $iBuffersize, $iForceBinary)
    $iErr = @error
    If $iErr Then ExitLoop
    If $sDwn And (Not $bDownloadActive) Then ExitLoop
    While StringLen($sRecv)
    If $iForceBinary Then $sRecv = BinaryToString($sRecv)
    If $iFirst Then
    If Not StringInStr($sRecv, "HTTP/1.1 200 OK") Then
    TCPCloseSocket($hSocket)
    If $sDwn Then FileClose($hFiOp)
    Return SetError(1, 1, "ERR:" & $sRecv)
    EndIf
    $Filelen = StringRegExp($sRecv,"(?i)Content-Length:\h(.*)",3)
    If Not @error Then $Filelen = $Filelen[0]
    $sFirstRecv = $sRecv
    If $sDwn Then $sRecv = StringTrimLeft($sRecv, StringInStr($sRecv, @CRLF & @CRLF)+4)
    $iFirst = False
    EndIf
    If $sDwn Then
    $iLen += StringLen($sRecv)
    ToolTip($iLen/$Filelen*100)
    FileWrite($hFiOp, $sRecv)
    EndIf
    If Not $sDwn Then $sRet &= $sRecv
    $sRecv = TCPRecv($hSocket, $iBuffersize, $iForceBinary)
    $iErr = @error
    If $iErr Then ExitLoop 2
    If $iTimeOut > 0 And TimerDiff($hTi) > $iTimeOut Then ExitLoop 2
    If $sDwn And (Not $bDownloadActive) Then ExitLoop 2
    WEnd
    Sleep($iSleep)
    WEnd
    ToolTip("")
    TCPCloseSocket($hSocket)
    If $sDwn Then FileClose($hFiOp)
    If $iForceBinary Then $sRet = "0x" & StringReplace($sRet, "0x", "")
    If $iTimeOut > 0 And TimerDiff($hTi) > $iTimeOut Then Return SetError(2, 0, "Timeout")
    If $iErr Then Return SetError(3, $iErr, $sRet)
    If Not $bDownloadActive Then Return SetError(4, 0, 0)
    Return $sRet
    EndFunc ;==>_HTTPRecv

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _INetGetSourceEx()
    ; Description: Gets the source from an URL without writing a temp file and you can send a Post.
    ; Also reads chunked Data.
    ; Parameter(s): $sURL = The URL of the site.
    ; $sPost = The Post to send
    ; Requirement(s): -
    ; Return Value(s): On Success - Return a array with $aReturn[0] = Backheader and $aReturn[1] = Sourcecode
    ; On Failure - 0 and sets @ERROR
    ; @error = 1: Post or URL is nothing
    ; @error = 2: Error by RegularExpression
    ; @error = 3: $sHost or $sHttp1 is nothing
    ; @error = 4: Can not get IP of Host
    ; @error = 5: Can not connect to host
    ; @error = 6: Nothing can be send
    ; @error = 7: Connection abborted while receiving
    ; Author(s): GtaSpider, Modified by Prog@ndy
    ;
    ;===============================================================================
    Func _INetGetSourceEx($sURL, $ReturnArray=True)
    Local $iSocket, $sHeader, $sRecv, $iIP, $sHost, $aRegExp, $sHttp1,$iErr,$iSend,$aReturn[2]
    If $sURL = '' Then Return SetError(1, 0, 0)
    If StringLeft($sURL, 7) <> 'http://' And StringLeft($sURL, 8) <> 'https://' Then $sURL = "http://" & $sURL
    $aRegExp = StringRegExp($sURL, "http?://(.*?)/", 3)
    If @error Then Return SetError(2, 0, 0)
    $sHost = $aRegExp[0]
    If $sHost = '' Then Return SetError(3, 0, 0)
    $sHttp1 = StringTrimLeft($sURL,StringInStr($sURL,"/",-1,3)-1)
    If $sHttp1 = '' Then Return SetError(3, 0, 0)
    $sHeader = "GET " & $sHttp1 & " HTTP/1.1" & @CRLF & _
    "Host: " & $sHost & @CRLF & _
    "User-Agent: AutoIt v3" & @CRLF & @CRLF
    TCPStartup() ;If not already done
    $iIP = TCPNameToIP($sHost)
    If $iIP = '' Or StringInStr($iIP, ".") = 0 Then Return SetError(4, 0, 0)
    $iSocket = TCPConnect($iIP, 80)
    If @error Or $iSocket < 0 Then Return SetError(5, 0, 0)
    $iSend = TCPSend($iSocket, $sHeader)
    If @error Or $iSend < 1 Then Return SetError(6, 0, 0)
    While 1
    $sRecv = TCPRecv($iSocket, 1024)
    $iErr = @error
    If $sRecv <> '' Then
    While 1
    $sRecv &= TCPRecv($iSocket, 1024)
    If @error Then ExitLoop 2
    WEnd
    EndIf
    If $iErr Then Return SetError(7,0,0)
    WEnd
    TCPCloseSocket($iSocket)
    TCPShutdown()
    $aReturn[0] = StringLeft($sRecv,StringInStr($sRecv,@CRLF&@CRLF)-1)
    $aReturn[1] = StringTrimLeft($sRecv,StringLen($aReturn[0])+4)
    ; Chunked Handler:
    If StringRegExp($aReturn[0],"(?i)Transfer-Encoding:\h*chunked") Then
    Local $ChunkedRes=$aReturn[1], $NextSize
    $aReturn[1]=""
    While 1
    $NextSize = StringRegExp($ChunkedRes,"\A(\w+)\h*\r\n",3)
    If @error Then ExitLoop
    $NextSize = Dec($NextSize[0])
    If $NextSize = 0 Then ExitLoop
    $ChunkedRes = StringRegExpReplace($ChunkedRes,"\A\w+\h*\r\n","")
    $aReturn[1] &= StringLeft($ChunkedRes,$NextSize)
    $ChunkedRes = StringTrimLeft($ChunkedRes,$NextSize+2)
    WEnd
    EndIf
    ; End Handler
    If Not $ReturnArray Then Return $aReturn[1]
    Return $aReturn
    EndFunc ;==>_INetGetSourcePost

    [/autoit]

    3 Mal editiert, zuletzt von Taek (1. Oktober 2008 um 14:50)