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. kackeldackel

Beiträge von kackeldackel

  • Aufwendige HTTP Requests bereiten Probleme

    • kackeldackel
    • 13. September 2015 um 12:54

    Ich hab auch mal ein

    Code
    $http.SetRequestHeader("Content-Length", "153")


    zugefügt, das Problem, ist da das gleiche. Wie übergeb ich diesen Content, aber ich muss mir mal die winhttp.au3 angucken, wenn es damit bequem geht, nutz ich einfach die.

  • Aufwendige HTTP Requests bereiten Probleme

    • kackeldackel
    • 12. September 2015 um 20:37

    Ein/ausloggen und Wiedereinwahl bekomme ich bei meinem Router hin, aber das Request um das Wlan an/aus zu machen bekomme ich nicht hin. Wie es aussieht, gibt es drei Teile woraus es besteht: der URL, dem Post und anscheinend auch noch dem Body, aber ich hab nicht herausgefunden, wie ich den bei winhttprequest.5.1 übermittle. Das einfach in die URL oder das POST zu stecken funktioniert nicht.

    So sehen das Login, Wlan anschalten und ausloggen im Browser aus:

    HTTP
    https://speedport.ip/index/login.cgi
    
    
    POST /index/login.cgi HTTP/1.1
    Host: speedport.ip
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Content-Length: 36
    Content-Type: text/plain; charset=UTF-8
    Referer: https://speedport.ip/
    Connection: keep-alive
    Pragma: no-cache
    Cache-Control: no-cache
    Username=admin&Password=asdfasdf1324
    HTTP/1.1 200 OK
    Set-Cookie: SessionID_R3=OaK5v3bU3Qk; path=/
    Content-Type: text/plain
    Content-Length: 25
    
    
    ----------------------------------------------------------
    https://speedport.ip/auth/setcfg.cgi?x=InternetGatewayDevice.LANDevice.1&y=InternetGatewayDevice.LANDevice.1.WLANConfiguration.1&RequestFile=/auth/hcti_netzwerk.php&cookie=SessionID_R3,OaK5v3bU3Qk
    
    
    POST /auth/setcfg.cgi?x=InternetGatewayDevice.LANDevice.1&y=InternetGatewayDevice.LANDevice.1.WLANConfiguration.1&RequestFile=/auth/hcti_netzwerk.php&cookie=SessionID_R3,OaK5v3bU3Qk HTTP/1.1
    Host: speedport.ip
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Cookie: SessionID_R3=OaK5v3bU3Qk
    Referer: https://speedport.ip/
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 153
    x.X_WLANEnable=1&y.Enable=1&y.X_DependOnScheduleRule=0&y.X_WlanStandard=g%2Fn&y.TransmitPower=20&y.X_MaxBitRateEnable=1&y.AutoChannelEnable=1&y.Channel=6
    HTTP/1.1 302 
    Cache-Control: no-cache
    Content-Type: text/html
    Location: https://speedport.ip/auth/hcti_netzwerk.php?cookie=SessionID_R3,OaK5v3bU3Qk
    Content-Length: 0
    ----------------------------------------------------------
    https://speedport.ip/auth/logout.cgi?RequestFile=/pub/top_beenden.php&cookie=SessionID_R3,OaK5v3bU3Qk
    
    
    POST /auth/logout.cgi?RequestFile=/pub/top_beenden.php&cookie=SessionID_R3,OaK5v3bU3Qk HTTP/1.1
    Host: speedport.ip
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Cookie: SessionID_R3=OaK5v3bU3Qk
    Referer: https://speedport.ip/
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 0
    
    
    HTTP/1.1 302 
    Cache-Control: no-cache
    Content-Type: text/html
    Location: https://speedport.ip/
    Content-Length: 0
    Alles anzeigen


    Das ist derQuellcode von meinem Script:

    Code
    #include <log.au3>
    
    
    ; ---- Login
    $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    $oHTTP.Open("POST", "http://speedport.ip/index/login.cgi", False)
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    $oHTTP.Send("Username=admin&Password=asdfasfsd123")
    _logit("login s: " & @error)
    ;Get received data
    $oStatusCode = $oHTTP.Status
    _logit("login: " & $oStatusCode)
    $oHeaderResponses = $oHTTP.GetAllResponseHeaders()
    ;ClipPut($oHeaderResponses)
    _logit("header: " & $oHeaderResponses)
    $oReceived = $oHTTP.ResponseText
    $file = FileOpen("R:\1login.html",2)
    FileWrite($file,$oReceived)
    FileClose($file)
    
    
    ; get session
    $cookie = StringRegExp($oHeaderResponses,"Set-Cookie: (SessionID_R3=\w{11}); path",3) ; SessionID_R3=eauTnzR0EeY für cookies
    $cookie = $cookie[0]
    _logit("cookie: " & $cookie)
    $session = StringReplace($cookie,"=",",") ; SessionID_R3,eauTnzR0EeY für urls
    
    
    
    
    
    
    
    
    
    
    $oHTTP.Open("POST", "https://speedport.ip/auth/setcfg.cgi?x=InternetGatewayDevice.LANDevice.1&y=InternetGatewayDevice.LANDevice.1.WLANConfiguration.1&RequestFile=/auth/hcti_netzwerk.php&cookie=" & $session, False)
    ; cookie
    $oHTTP.SetRequestHeader("Cookie", $cookie)
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    ;Send POST request
    $oHTTP.Send("x.X_WLANEnable=1&y.Enable=1&y.X_DependOnScheduleRule=0&y.X_WlanStandard=g%2Fn&y.TransmitPower=20&y.X_MaxBitRateEnable=1&y.AutoChannelEnable=1&y.Channel=6")
    _logit("wlan s: " & @error)
    ;Get received data
    $oStatusCode = $oHTTP.Status
    _logit("wlan: " & $oStatusCode)
    $oHeaderResponses = $oHTTP.GetAllResponseHeaders()
    _logit("header: " & $oHeaderResponses)
    $oReceived = $oHTTP.ResponseText
    $file = FileOpen("R:\2wlan.html",2)
    FileWrite($file,$oReceived)
    FileClose($file)
    
    
    
    
    
    
    $oHTTP.Open("POST", "http://speedport.ip/auth/logout.cgi?RequestFile=/pub/top_beenden.php&cookie=" & $session, False)
    $oHTTP.SetRequestHeader("Cookie", $cookie)
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    $oHTTP.Send()
    _logit("logout s: " & @error)
    ;Get received data
    $oStatusCode = $oHTTP.Status
    _logit("logout: " & $oStatusCode)
    $oHeaderResponses = $oHTTP.GetAllResponseHeaders()
    _logit("header: " & $oHeaderResponses)
    $oReceived = $oHTTP.ResponseText
    $file = FileOpen("R:\3logout.html",2)
    FileWrite($file,$oReceived)
    FileClose($file)
    
    
    Sleep(12345)
    Alles anzeigen


    Log.au3 ist nur fürs (Debug)Output da:

    C
    #include <GUIConstantsEx.au3> ; var for on close event
    #include <WindowsConstants.au3> ; var for resizable
    
    
    Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
    
    
    $fensterx = 515 ; ui width
    $fenstery = 300 ; ui heigth
    $guiwintext = StringLeft(@ScriptName,StringLen(@ScriptName)-4)
    
    
    $guiwin = GUICreate($guiwintext,$fensterx,$fenstery,600,700,$WS_OVERLAPPEDWINDOW) ;creates the resizable loggui
    GUISetOnEvent($GUI_EVENT_CLOSE, "_log_win_close") ;  registering the close event
    $guiedit = GUICtrlCreateEdit("Starting up...",0,0,$fensterx,$fenstery) ;creates the textfield in the gui
    GUISetState(@SW_SHOW) ; shows it
    Func _log_win_close()
    	Exit
    EndFunc
    Func _logit($text)
    	GUICtrlSetData($guiedit, @HOUR & ":" & @MIN & ":" & @SEC & " " & $text & @CRLF, "append") ; creates logentry
    EndFunc   ;==>_logit
    Func _clear_edit_box()
    	$tmp = GUICtrlRead($guiedit)
    	;If StringLen($tmp) > 29500 Then
    	If StringLen($tmp) > 20000 Then
    		GUICtrlSetData($guiedit,StringTrimLeft($tmp,5000))
    	EndIf
    EndFunc   ;==>_clear_edit_box#include <GUIConstantsEx.au3> ; var for on close event
    #include <WindowsConstants.au3> ; var for resizable
    
    
    Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
    
    
    $fensterx = 515 ; ui width
    $fenstery = 300 ; ui heigth
    $guiwintext = StringLeft(@ScriptName,StringLen(@ScriptName)-4)
    
    
    $guiwin = GUICreate($guiwintext,$fensterx,$fenstery,600,700,$WS_OVERLAPPEDWINDOW) ;creates the resizable loggui
    GUISetOnEvent($GUI_EVENT_CLOSE, "_log_win_close") ;  registering the close event
    $guiedit = GUICtrlCreateEdit("Starting up...",0,0,$fensterx,$fenstery) ;creates the textfield in the gui
    GUISetState(@SW_SHOW) ; shows it
    Func _log_win_close()
    	Exit
    EndFunc
    Func _logit($text)
    	GUICtrlSetData($guiedit, @HOUR & ":" & @MIN & ":" & @SEC & " " & $text & @CRLF, "append") ; creates logentry
    EndFunc   ;==>_logit
    Func _clear_edit_box()
    	$tmp = GUICtrlRead($guiedit)
    	;If StringLen($tmp) > 29500 Then
    	If StringLen($tmp) > 20000 Then
    		GUICtrlSetData($guiedit,StringTrimLeft($tmp,5000))
    	EndIf
    EndFunc   ;==>_clear_edit_box
    Alles anzeigen


    Das Problem scheint diese Passage zu sein:

    Code
    Content-Length: 153
    x.X_WLANEnable=1&y.Enable=1&y.X_DependOnScheduleRule=0&y.X_WlanStandard=g%2Fn&y.TransmitPower=20&y.X_MaxBitRateEnable=1&y.AutoChannelEnable=1&y.Channel=6


    Wie gebe ich die denn bei Autoti weiter?

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™