|
You last visited: Today at 17:56
Advertisement
HTTP requests
Discussion on HTTP requests within the AutoIt forum part of the Coders Den category.
02/29/2016, 00:00
|
#1
|
elite*gold: 1908
Join Date: Jan 2013
Posts: 832
Received Thanks: 629
|
HTTP requests
Hello guys!
I want to create a simple script which will show me how much resources or soldiers I have on my game acount.
Game's name is Travian.
I have already tried to do it for several hours but it seems impossible for me. (I know how GET or POST works but I can't figure out how to do it. I watched many tuts but it didn't help me too).
This is what I have:
Code:
#include <WinHttp.au3>
#include <Array.au3>
#include <String.au3>
Global $user="ssamko"
Global $pass="autoit123"
Local $url= BinaryToString(InetRead( "http://ts5.travian.sk/?lang=sk" ))
$token=_StringBetween($url,'name="login" value="','"')
$token=$token[0]
$login_url="http://ts5.travian.sk/login.php"
$login= ObjCreate("WinHttp.WinHttpRequest.5.1")
$login_packet="name=ssamko&password=autoit123&s1=Login&w=1920%3A1080&login="&$token&"&lowRes=0"
$login.open("POST", $login_url)
$login.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$login.send($login_packet)
$login.WaitForResponse()
$cookies = $login.getresponseheader("Set-Cookie")
ConsoleWrite($cookies&@CRLF&@CRLF)
Login page:
name: ssamko
password: autoit123
I want only script which will get data like amount of wood, gold or something like that+ finally I will learn how to do it (I play with autoit for about a year...but HTTP requests are my death )
I would be very thankful for help !
|
|
|
02/29/2016, 00:42
|
#2
|
elite*gold: 100
Join Date: Oct 2009
Posts: 348
Received Thanks: 20
|
Try This  My english is very bad
#include <WinHttp.au3>
#include <string.au3>
#include <array.au3>
$Name = "ssamko"
$Pass = "autoit123"
Main()
Func Main()
$hseassion = _winhttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0")
$hconnect = _WinHttpConnect($hseassion, "http://ts5.travian.sk/login.php")
$sHTML = _WinHttpSimpleRequest($hconnect, "GET", "") ;startseite
$sHTML = _WinHttpSimpleRequest($hconnect, 'Post','/dorf1.php','ts5.travian.sk',"name="&$Name&"&passwo rd="&$Pass&"&s1=Login&w=1280%3A800&login=145670198 6"); eingeloggt
;FileWrite("Test1.html",$sHTML)
$Drevo = (_StringBetween($sHTML,'<span id="l1" class="value">',"<"))[0]
$Hlina = (_StringBetween($sHTML,'<span id="l2" class="value">',"<"))[0]
$Zelezo = (_StringBetween($sHTML,'<span id="l3" class="value">',"<"))[0]
$Obilie = (_StringBetween($sHTML,'<span id="l4" class="value">',"<"))[0]
MsgBox("","",$Drevo&" "&$Hlina&" "&$Zelezo&" "&$Obilie)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hseassion)
EndFunc
|
|
|
02/29/2016, 09:04
|
#3
|
elite*gold: 1908
Join Date: Jan 2013
Posts: 832
Received Thanks: 629
|
Quote:
Originally Posted by Benny.Sv
Try This  My english is very bad
#include <WinHttp.au3>
#include <string.au3>
#include <array.au3>
$Name = "ssamko"
$Pass = "autoit123"
Main()
Func Main()
$hseassion = _winhttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0")
$hconnect = _WinHttpConnect($hseassion, "http://ts5.travian.sk/login.php")
$sHTML = _WinHttpSimpleRequest($hconnect, "GET", "") ;startseite
$sHTML = _WinHttpSimpleRequest($hconnect, 'Post','/dorf1.php','ts5.travian.sk',"name="&$Name&"&passwo rd="&$Pass&"&s1=Login&w=1280%3A800&login=145670198 6"); eingeloggt
;FileWrite("Test1.html",$sHTML)
$Drevo = (_StringBetween($sHTML,'<span id="l1" class="value">',"<"))[0]
$Hlina = (_StringBetween($sHTML,'<span id="l2" class="value">',"<"))[0]
$Zelezo = (_StringBetween($sHTML,'<span id="l3" class="value">',"<"))[0]
$Obilie = (_StringBetween($sHTML,'<span id="l4" class="value">',"<"))[0]
MsgBox("","",$Drevo&" "&$Hlina&" "&$Zelezo&" "&$Obilie)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hseassion)
EndFunc
|
You are my hero ! Thank you so much !
|
|
|
 |
Similar Threads
|
[Java] Grundlage aller böser Absichten im Web: Http Requests
01/17/2011 - Coding Tutorials - 0 Replies
Huhu liebe Community!
Hatte in letzter Zeit viel Zeit. Naja, das fängt stil-technisch schon mal gaaaanz unschön an...
Whatever, ich habe mich mit Package Bots und Brute Force Programmen beschäftigt; So habe ich min 4 Wochen lang an einem (SDS) Staemme Bot gearbeitet, das Projekt liegt mittlerweile auf Eis, wie fast alle Privatprojekte.
An diese Stelle, falls wer Interesse an den Sourcen hat und mit meinem SpagetthiCode klarkommt, immer her mit den Anfragen...
Grunlage all dieser aus...
|
Looking for informations on HTTP-Requests
08/24/2009 - Browsergames - 1 Replies
Hi @ all,
I try to write a bot witch will train own Brutes.
Unlike other bots is a list of weak opponents sorted according their levels.
The Brute will then trained against opponents 2 levels lower as the own ones because that increase the chance of 2-point victories ;) There will be easy to edit lists for the weak opponents and the own brutes so that everyone may edit them for there own needs.
So far so good, what I lack is simply the corresponding HTTP-requests and HTTP-responses...
|
All times are GMT +1. The time now is 17:57.
|
|