1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Sapp

Beiträge von Sapp

  • Cookies nicht aktiviert?

    • Sapp
    • 23. Mai 2014 um 17:17

    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

    [/autoit][autoit]

    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

    [/autoit][autoit]

    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

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

    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

    [/autoit]

    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

  • Cookies nicht aktiviert?

    • Sapp
    • 11. Mai 2014 um 15:26

    Danke für die Antwort schonmal.. Habe mit LiveHeaders folgendes herausgefunden..
    Beim Laden der Seite, ist dieser Cookie gesetzt:

    Code
    Cookie: reg_fb_gate=https://m.facebook.com/r.php; datr=iLBuU8jCpB6dKsoKogc6LK9f


    Beim Abschicken der Form:

    Code
    Set-Cookie: reg_uniqid=536eb0e06dc85; domain=.facebook.com; httponly
    Set-Cookie: reg_ext_ref=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com

    Umzusetzen ist das mit _WinHttpAddRequestHeaders so wie ich das bisher gelesen habe.. aber wie genau (man findet nicht so viel dazu im Internet)

    Und wegen den ToS, ich hab mir Facebook halt mal als Beispiel genommen, um bisschen rumzuexperimentieren.. Wenn der Account gelöscht werden sollte, ist das für mich nebensächlich :P

  • Cookies nicht aktiviert?

    • Sapp
    • 10. Mai 2014 um 17:41

    Hallo,
    ich beschäftige mich seit paar Tagen mit autoIt und will damit bisschen rumexperimentieren. Habe nun aber folgendes Problem und bekomme es iwie nich gelöst -.-
    Ich sende per WinHTTP POST- Daten, jedoch wird mir von der Seite immer wieder angezeigt, dass keine Cookies aktiviert wären.. muss man mit WinHTTP Cookies manuell setzen?

    POST Funktion

    Code
    Func _Post($Post, $Link, $connection)
       local $data = ""
       $data = _WinHttpSimpleSSLRequest($connection, 'Post', $Link, Default, $Post )
    
    
       Return $data
    EndFunc

    Ausschnitt aus der betroffenen Funktion

    Code
    local $connect = _WinHttpConnect($hw_open, "m.facebook.com")
    
    
       local $PostRequest = _Post($PostVal, "/r.php", $connect)

    Die Post Daten werden vorher auch in HTML Standard umgewandelt, also liegt auch nicht daran..

    Wäre schön, wenn ihr mir hefen könntet, vielen Dank :)

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™