Habe das ganze jetzt angepasst und mir _Post und _Get Funktionen gebastelt (Grundfunktionen von brugbart.com)
[autoit]Func HttpPost($sURL, $sData = "", $cookies = false)Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("POST", $sURL, False)If (@error) Then Return SetError(1, 0, 0)if($cookies) Then $oHTTP.SetRequestHeader("Cookie", DeliverCookies())EndIf;$oHTTP.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0");$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($sData)if($cookies) Then GetCookies($oHTTP)EndIfIf (@error) Then Return SetError(2, 0, 0)
If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0)
Return SetError(0, 0, $oHTTP.ResponseText)EndFunc
Func HttpGet($sURL, $sData = "", $cookies = false)Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("GET", $sURL & "?" & $sData, False)If (@error) Then Return SetError(1, 0, 0)if($cookies) Then $oHTTP.SetRequestHeader("Cookie", DeliverCookies())EndIf;$oHTTP.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
$oHTTP.Send()if($cookies) Then GetCookies($oHTTP)EndIfIf (@error) Then Return SetError(2, 0, 0)
If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0)
Return SetError(0, 0, $oHTTP.ResponseText)EndFunc
func GetCookies($oHTTP) $HeaderResponses = $oHTTP.GetAllResponseHeaders()
; Handle Cookies $array = StringRegExp($HeaderResponses, 'Set-Cookie: (.+)\r\n', 3) $cookies = '' for $i = 0 to UBound($array) - 1 ; Add all cookies to a single string, and then clean it up. $cookies = $array[$i] & ';'
; Getting the name of the Current Cookie $cookname = StringRegExpReplace($cookies, "([^=]+)=.+", "$1")
; Removing parts we do not use.. $cookies = StringRegExpReplace($cookies, "( path| domain| expires)=[^;]+", "") $cookies = StringRegExpReplace($cookies, " HttpOnly", "") $cookies = StringRegExpReplace($cookies, "[;]{2,}", ";")
; Save the cookies to .txt files ; Delete the file if it already exists FileDelete ("Cookies" & $cookname & ".txt") $file = FileOpen("Cookies" & $cookname & ".txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file: " & $cookname) Exit EndIf FileWrite($file, $cookies) FileClose($file)
NextEndFunc
Func DeliverCookies() ; Search for files in the cookie directory and add them to the cookies variable, seperated by ",,," $search = FileFindFirstFile("Cookies" & "*.*") If $search = -1 Then return 'none' EndIf $cookies = '' While 1 $file = FileFindNextFile($search) If @error Then ExitLoop
if($cookies = "") Then $cookies = $file Else $cookies = $cookies & ',,,' & $file EndIf
WEnd FileClose($search)
;$cookies = StringTrimLeft($cookies, 3) ; Fix the string
; Split the cookies into an array ; then read the files one by one, and add their contents to the cookie variable $array = StringSplit($cookies, ',,,', 1)
$counter = 1 $cookie = '' While $counter <= $array[0] ;MsgBox(0, "File: ", $array[$counter])
$file = FileOpen("Cookies" & $array[$counter], 1) If $file = -1 Then MsgBox(0,"","9203131") Exit EndIf
$cookie = $cookie & FileRead("Cookies" & $array[$counter], -1) FileClose($file) $counter = $counter + 1 WEnd Return $cookieEndFunc
Nach wievor jedoch dasselbe Problem -_
Edit: Die Formatierung des Codes lässt sich hier iwie nicht anständig darstellen.. daher hier nochmal: http://pastebin.com/7YQ5G2LT