Baymax Posted June 17, 2015 Share Posted June 17, 2015 Hi everybody.I'm a newbie autoit. I want login site http://teespring.com/ by winhttp Here is my code expandcollapse popup#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 More sharing options...
Danp2 Posted June 17, 2015 Share Posted June 17, 2015 Can you explain why you are using winhttp to log into the site? What do you intend to do once logged in? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
GMK Posted June 17, 2015 Share Posted June 17, 2015 Not sure what your ultimate goal is here, but you might look into using _WinHttpSimpleFormFill to log in. Link to comment Share on other sites More sharing options...
GMK Posted June 17, 2015 Share Posted June 17, 2015 Just noticed something: change Line 7 of your code$hconnect = _WinHttpConnect($hopen,"https://teespring.com/login")to$hconnect = _WinHttpConnect($hopen,"teespring.com") Link to comment Share on other sites More sharing options...
trancexx Posted June 17, 2015 Share Posted June 17, 2015 (edited) 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 June 17, 2015 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Baymax Posted June 17, 2015 Author Share Posted June 17, 2015 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 More sharing options...
trancexx Posted June 18, 2015 Share Posted June 18, 2015 You can do that, there's API available. I just made a shirt to test it. Baymax 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Baymax Posted June 19, 2015 Author Share Posted June 19, 2015 Please Show me your code to upload new design test on teesping. Thanks u Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now