Hallo!
Hat zufällig jemand ein Script zur Hand, mit dem man bei Rapidshare Dateien runterladen kann? Ich bin mit einem Beispiel aus dem englischen Forum am verzweifeln.
Falls nicht, dann könnte mir vielleicht jemand beim Code weiterhelfen...
EDIT: Etwas weiterentwickelt, funktioniert aber immer noch nicht:
Spoiler anzeigen
#include <String.au3>
[/autoit] [autoit][/autoit] [autoit]Global $bDownloadActive = False
$thanks1 = "http://rapidshare.com/files/140030178/thanks4.dl"
Download($thanks1)
;===============================================================================
;
; Function Name: Download
; Description:: Download a file as a free user
; 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 Download($sURL)
Local $sSendString, $hSocket, $sRecv, $iExt, $aRegEx, $sRet
TCPStartup()
$source1 = _INetGetSourcePost($sUrl,"dl.start=Free")
$link = _StringBetween($source1[1],'action="','" method')
$source2 = _INetGetSourcePost($link[1], "dl.start=Free")
$directlink = _StringBetween($source2[1], "dlf.action=\'", "\';")
;Sleep(31*1000)
$split = StringSplit($link[1],".")
$server = StringTrimLeft($split[1],7)
If Not $server = "" Then
$hSocket = TCPConnect(TCPNameToIP($server&".rapidshare.com"), 80)
If @error Then Return SetError(1, @error, 0)
$sGet = Stringsplit($sURL,".rapidshare.com",1)
$sSendString = "GET " & $directlink[1] & " HTTP/1.1" & @CRLF & _
"Host: "& $server & ".rapidshare.com" & @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 & _
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @CRLF & _
"Keep-Alive: 300" & @CRLF & _
"Connection: keep-alive" & @CRLF & _
"Referer: " & $link[1] & @CRLF & _
"Connection: keep-alive" & @CRLF & @CRLF
MsgBox(0,"",$sSendString)
_HTTPSend($sSendString, $hSocket)
If @error Then SetError(2, 0, 0)
$bDownloadActive = True
$sRecv = _HTTPRecv($hSocket, 50, 0,@ScriptDir, 1)
If @error = 4 Then Return SetError(6, 0, 0)
Return True
EndIf
TCPShutdown()
EndFunc ;==> Download
;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
;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
$sFirstRecv = $sRecv
If $sDwn Then $sRecv = StringTrimLeft($sRecv, StringInStr($sRecv, @CRLF & @CRLF)+4)
$iFirst = False
EndIf
If $sDwn Then
$iLen += StringLen($sRecv)
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
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
;===============================================================================
;
; 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, <> '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
$aReturn[0] = StringLeft($sRecv,StringInStr($sRecv,@CRLF&@CRLF)-1)
$aReturn[1] = StringTrimLeft($sRecv,StringLen($aReturn[0])+4)
Return $aReturn
EndFunc ;==>_INetGetSourcePost
GtaSpider : Es geht doch in Ordnung, dass ich deine schöne _RapidPrem_Download etwas verwurschtel oder?