Oct 08

MyBot Tutorial Part 1

Some time ago I was planning to make a series of tutorials to explain how you can make your own bots for browser games. Now I’m finally starting with it :).

There are different ways to make a bot, in the “MyBot” tutorials I will explain how you can make a bot that uses http requests.

The first step to make when starting with a bot is playing the game in your browser and watching the http requests. There are many tools for this that you can use. The easiest method is using a Firefox plugin called Live HTTP Header. Or if you want to use a separate program you can use WireShark.

There are two types of http requests. The GET requests and the POST requests. While using one of the above tools you will see that most of the requests are a GET request.
A GET requests does nothing more then returning the data you requested. So when browsing through a site clicking some links, that will be GET requests.
A POST request does also return the data you requested just like the GET request but with a POST request you can also send data with the request. This is almost always used when you have to fill in a form. An example were this is used is by all the browser based games when you login by entering your username and password.

For an example of a GET request you can go to the following page while using one of the above tools. I’ll be using Live HTTP Headers in this tutorial. In Live HTTP headers you will see the following:

MyBot GET Request

You see that the third line starts with GET. That means it’s a GET request. For a http GET request only two lines are really important and that is the GET request and the host.

GET /files/MyBotTutorial.html HTTP/1.1
Host: bots.uthar.nl

The advantage of the addon Live HTTP headers is that it already combines those two lines to show the full address, see the first line. With these two lines you have all the information you need to create your own request. The other lines can also be interesting but are not needed at this point. I’ll explain some of them in later parts of the tutorial.

MyBot POST Request

The second picture is a POST request. The request in the picture is from the browser game Grepolis when you try to train some units. For POST requests you will need some more information. Just like the GET requests you need information about the request itself and the host. When you use Live HTTP headers see the first line.

POST /game/building_barracks?action=build&town_id=00000&h=0CQWKifC HTTP/1.1
Host: en3.grepolis.com

As explained earlier you can send data with a POST request. This is called the content. There are two lines that give information about this, the Content-Length and the content itself (last line).

Content-Length: 20

The content contains a number of name-value pairs that are separated with the &-char.

This are the basics you need to know to work with http requests. In the next part of the tutorial I’ll explain how you can write C# code to make your own POST and GET requests.


1 ping

Skip to comment form

    • antoni on July 22, 2011 at 23:18
    • Reply

    I think I should make a video for us to better specify and understand how to create our bot..

  1. Personally I think you don’t need a video tutorial for this. The best way to learn this is just making a small program and practice with the possibilities.
    And you can always ask questions of course.

    • m on March 12, 2012 at 10:45
    • Reply

    Nice tutorials. I’ve been making browser based bots for a while, but instead of live http headers or wireshark I use: http://fiddler2.com/fiddler2/ Makes life easier because it track everything from your bot too so you can see exactly what it being sent and recieved easily.

    Keep up the good work o/

  2. Thanks m.
    I know fiddler too but I have tried it only a few times. Currently I’m using the firefox addon Firebug, works great.

    • mich on April 21, 2012 at 16:35
    • Reply

    My friend! I had problems coz in my country r restrictions to do payment in other type of currency if it isn’t the national money…
    I don’t have the chance to do it in that way. But if u have other form to donate? or other chance to get the bot complete I’ll appreciate all ur help…

    1. I tried a few alternatives but I’m not going to do that again. Paypal only for now, sorry.

    • badguy4you on July 6, 2012 at 01:29
    • Reply

    MAN i am trying to use this in Travian but seems not to work ALSO how could i see the results in webbrowser control to be more easy ?

    1. I have also answered your private message at epvp, maybe it’s easier to answer your questions there.

      This should however also work for Travian.

    • Tang on July 27, 2012 at 13:35
    • Reply

    Hi Uthar,

    I have some questions about the grepolis bot source code.
    Is it based on the latest version of the bot?
    And what are the functions implemented in this source?
    Are they all functionnal?
    I ask this because I am studying the possibility of a small application allowing me to replace some functions of the administrator in this game.


    1. Not it’s an old version. I stopped releasing the new source code when I added server validation to the bot.
      The structure is however still the same but you will have to update some of the server requests, including the login request.

    • Davin on October 7, 2014 at 17:42
    • Reply

    I donated about 3 days ago and still unable to use any of the applications.

    1. What do you mean by “applications”? The only active project is the Grepolis bot and you can use that without donating, although extra features are available for those who donate.

      What email address did you use when making the donation? Because I haven’t received anything from the email address in your comment.

    2. I saw the email you send me, did you it working?

    • Jérémy SIMON on June 5, 2015 at 19:11
    • Reply

    Hi Uthar,

    I’ve POST :

    I don’t know if it’s httpS but the post seems crypted and send via JSON, how did u handle the S of https in the last version ?

    PS : I’m trying to do it in Python, i don’t handle connection i use browser_cookie to get Chrome Cookies in my app.

    1. Sorry for the delayed response, your message was marked as spam.

      Regarding https, not much changes were necessarily. The bot uses two connections, one for the browser tab and one for the server requests made by the bot. I’m using the (session) cookies to sync both connections.
      After changing the urls to https the bot was still able to get the session cookies and everything remained functional.

      What do you mean by encrypted? the url?
      It is not really an encryption but if you copy/paste your url here and press decode you can make it more readable:

        • Jérémy SIMON on June 18, 2015 at 19:04
        • Reply

        Thank you for answering. The main problem i had was to handle the connection without the Grepolis tab. Thing i saw in your source code you handle by faking a user typing the credentials. I really wanted to handle it with post request but it seems impossible. I maybe have a look in the future to mechanize and make the same thing you did but in python.
        I’ll try to make a Chrome Extension in Javascript to set up a bot in tab. I’m learning and practicing. Thank you Uthar for your bot :).

    • Auth0x on October 19, 2015 at 21:53
    • Reply

    Hello, i’m the guy from GitHub ^^

    I’m building a bot for another browsergame and i’m studing yours to get ideas on how to do some things, but i’m proceding slowly since it’s a quite big project and it’s using patterns i don’t know.
    Could you explain in details how the building queue (and timer) works?

    1. Mail send

  1. […] « MyBot Tutorial Part 1 […]

Leave a Reply

Your email address will not be published.

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera