Jump to content

Problem login site with winhttp


Recommended Posts

Hi everybody.

I'm a newbie autoit. I want login site http://teespring.com/ by winhttp 

Here is my code 

#include <winhttp.au3>
#include <zlib.au3>
#include <string.au3>
#include <array.au3>

$hopen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0")
$hconnect = _WinHttpConnect($hopen,"https://teespring.com/login")
$hRequest = _WinHttpOpenRequest($hconnect,"GET","/login","HTTP/1.1",'','',$WINHTTP_FLAG_SECURE)
_WinHttpAddRequestHeaders($hRequest,"Host: teespring.com")
_WinHttpAddRequestHeaders($hRequest,"User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0")
_WinHttpAddRequestHeaders($hRequest,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
_WinHttpAddRequestHeaders($hRequest,"Accept-Language: en-US,en;q=0.5")
_WinHttpAddRequestHeaders($hRequest,"Accept-Encoding: gzip, deflate")
_WinHttpSendRequest($hRequest)

If (_WinHttpReceiveResponse($hRequest)==1) Then
    Local $Header = _WinHttpQueryHeaders($hRequest)
    Local $Data = _WinHttpSimpleReadData($hRequest, 2)
    ConsoleWrite($Header)
    $cookie = _StringBetween($Header,"Set-Cookie: ",";")
    $data1 = BinaryToString(_ZLIB_GZUncompress($Data),4)
    $ls = StringRegExp($data1,'<meta content="(.+?)" name="csrf-token" />',3)
EndIf
_WinHttpCloseHandle($hrequest)
$post ="utf8=%E2%9C%93&authenticity_token="&__WinHttpURLEncode($ls[0])&"&email=baymax%40gmail.com&password=baymax"
MsgBox(0,'',$post)
ClipPut($post)
$hRequest = _WinHttpOpenRequest("POST","/sessions","HTTP/1.1",'','',$WINHTTP_FLAG_SECURE)
_WinHttpAddRequestHeaders($hRequest,'Host: teespring.com')
_WinHttpAddRequestHeaders($hRequest,'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
_WinHttpAddRequestHeaders($hRequest,'Accept-Language: en-US,en;q=0.5')
_WinHttpAddRequestHeaders($hRequest,'Accept-Encoding: gzip, deflate')
_WinHttpAddRequestHeaders($hRequest,'Referer: https://teespring.com/login')
_WinHttpAddRequestHeaders($hRequest,'Cookie: '&$cookie[0]&';'&$cookie[3])
_WinHttpAddRequestHeaders($hrequest,"Content-Length: "&StringLen($post))
_WinHttpSendRequest($hrequest,"Content-Type: application/x-www-form-urlencoded",$post)
_WinHttpCloseHandle($hrequest)

$hRequest = _WinHttpOpenRequest($hconnect,'GET','/','HTTP/1.1','','',$WINHTTP_FLAG_SECURE)
_WinHttpAddRequestHeaders($hRequest,'User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0')
_WinHttpAddRequestHeaders($hRequest,'Host: teespring.com')
_WinHttpAddRequestHeaders($hRequest,'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
_WinHttpAddRequestHeaders($hRequest,'Accept-Language: en-US,en;q=0.5')
_WinHttpAddRequestHeaders($hRequest,'Connection: keep-alive')
_WinHttpAddRequestHeaders($hRequest,'Cookie: '&$cookie[0]&';'&$cookie[3])
_WinHttpSendRequest($hRequest)
If (_WinHttpReceiveResponse($hRequest)==1) Then
    Local $Header = _WinHttpQueryHeaders($hRequest)
    Local $Data = _WinHttpSimpleReadData($hRequest, 2)
    ConsoleWrite($Header)
EndIf
_WinHttpCloseHandle($hrequest)

 But it not working. Help me?

Link to comment
Share on other sites

You could do it like this:

#include "WinHttp.au3"

$sEmail = "baymax@gmail.com"
$sPassword = "baymax"

; Open session
$hOpen = _WinHttpOpen()
; Connection to make
$hConnect = _WinHttpConnect($hOpen, "https://teespring.com")

; Fill the form
$sRead = _WinHttpSimpleFormFill($hConnect, "/login", Default, _
        "name:email", $sEmail, _
        "name:password",$sPassword)

; Close handles
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

ConsoleWrite($sRead & @CRLF)

 

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

You could do it like this:

#include "WinHttp.au3"

$sEmail = "baymax@gmail.com"
$sPassword = "baymax"

; Open session
$hOpen = _WinHttpOpen()
; Connection to make
$hConnect = _WinHttpConnect($hOpen, "https://teespring.com")

; Fill the form
$sRead = _WinHttpSimpleFormFill($hConnect, "/login", Default, _
        "name:email", $sEmail, _
        "name:password",$sPassword)

; Close handles
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

ConsoleWrite($sRead & @CRLF)

 

I want after Login i can take action in page such as upload new design,manager campaign or get messages

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...