Results 1 to 2 of 2

Thread: Python - Kayses Tutorials Part one - Logging in with neoaccount

  1. #1
    Join Date
    Jun 2012
    90 90
    Thanked 2,875 Times in 1,139 Posts

    562 Post(s)
    Time Online
    118 d 6 h 45 m
    Avg. Time Online
    1 h 55 m
    Rep Power
    Gamer IDs

    Gamertag: DarkByt3 PSN ID: raredaredevil

    Python - Kayses Tutorials Part one - Logging in with neoaccount

    These tutorials where created for a freind @kaysevicious. There is typos and I don't talk very professionally but I hope someone else can benefit from these. Kayse knows some programming already so forgive me for jumping into this..

    Creating cheats for web based games for kayse Part One

    When we make a cheat for web based games we are essentially always using the same methods. The process usually go's

    1.Get the html to a page.

    2.Extract data from this pages html.

    3.Do something with this data and perform something based on this.

    No matter what we are doing , this usually remains true. Our first step however is using NeoAccount class to login to neopets. By the end of our guides you will be able to read the code to neoaccount and know how it all works. However for now we will keep this simple. A breif explanation would be it is our “httpwrapper”. It performs a http get/post request (a request to a webpage) and then returns the html for us to a string. It also remembers cookies for us and saves any logins we perform. Neoaccount class includes a login function we can use already. It is included in this file ( open it with idle and have a look through the code while we are using it. You might not understand it all but it will help you understand a lot of what we will use here.

    Included attached to this post

    \lessons files\ - Files needed to follow this guide (
    \completed project\ - The code when this tutorial is finished , check against this if you have issues

    Step 0.1 – Project Setup

    Create a new folder somewhere (for me on my desktop because im a slob). And extract the file to this location.

    Step 0.2 – Logging in

    Open idle and goto File - > New window , to bring up a code window. Save this empty file as to your folder aswell. Next we will login and check the result I added a test account in the project files to save effort:

    I will now explain this code line by line.

    This tells python we want to include the code from when this file is loaded.

    Here we are making a new string called neouser and giving it a value (enter ur username here)

    Here we are making a new string called neopass and giving it a value (enter ur password here)

    This sets a new variable called acc and loads the class from the Neoaccount file into it. We can now call acc.function_name() to make functions inside the neoaccount file execute.

    This sets a new variable called theresult and saves the results of the function acc.login() to it. This code is found in neoaccount.pu under the login function. Have a read of it , you will understand it all soon.

    This just prints out the result into out run window when we press run. We can remove this line when we finish testing as we wont need to see it all the time. But for now its usefull to use to see whats going on internally. You should use this a lot in code to check everything is running as it should. You will see me use it a lot from now on and not really explain it. But this is what we are using it for.

    Next press Run - > Run Module (F5) To make this file execute.
    The script outputs this:
    (True, 'Logged in')

    This the return from the acc.login function. It is a list a (collection of varibles). The first varible is a bool (if it was a string it would have quotes) the second item is a String.

    A string is a word it can be identified because it in quotes - 'I am a string'
    A integer is a number , string can also hold numbers , but you cannot use math functions on them. You can distinguish between the two because a int will not have quotes.
    A boolean is either True or False (without quotes)
    A list is a collection of the above , it can contain string , bools and integers. This is what a list looks like:

    (True, 'This is our string' , 1234)

    The above list contains 2 items. When programming we always count from 0 so...

    0=True (Boolean)
    1='This is our string' (String)
    2=1234 (Integer)

    Armed with this we know that from our last code theresult now contains a list with this data:
    (True, 'Logged in')

    To access this data we slice the list like so

    Add this to the end of your code. All we are doing is is making loginbool and loginmsg print there contents.

    Our script now outputs this:

    Everything is working as expected , remove all lines that print from your code (there should be 3). We know whats going on now and wont need them so lets keep our output clean for the next steps. We now know that if the user is logged in loginbool will be True. Let us detect this by adding this code...

    Lets break that down...

    Login bool contains the bool from our acc.login result it will be true if slice 0 = True (boolean)

    Note how this is alighned to the right by hitting tab once. This is because the code is inside the previous IF() code. YOU MUST stick to this alighnmient rule unlike other languages that use things like this

    Python does not use this. Instead it is all by the margins. Its kind of cool because it forces u to stay neat . But a bit confusing at first.

    This is back on the same line as the previous if statement it tells the code that the else matches that if and must be on the same margin as the relevant if. A else tells our code that when the previous if statement is false to always execute the following code.

    One tab in again! As this code is only inside the else statement. This just prints the string “Login error” if our bool is not true. Lets execute our code and see that happens for me it says :

    “logged in”

    This was expected. Now change the password of the account to something invalid and run the script again. The output is now “Login error” this was also expected because we rock and our if statements working. Next leave the bad password still and add this to the top of your code (first line)

    This is a file included with python to use some built in functions. Next add this line of code to the LAST line of code

    (include tab space)

    This tells the program to exit the application if the above code did not work (in this case we got a bad login). It does the by using the internal function exit , from the class sys. (you can find info on included classes on google , pretty much by googling what it is ur trying to do when you need it). The second line of code is just there to show us the application actually closed. If it closes that line will never be executed.

    Run our code again and lets see what happens. It works as expected. The program executes and exits because we left our password invalid still. Now change it back to the real login and we are done. This is our login code done. And code we added under this would only get executed if we are logged in. Finally before we end this lets just verify our login by adding this code to the end of our script:

    Now close the “python shell window” so when we run again we get a clean one (our script will stay open). Run the script and you will see a whole bunch of html print out into a fresh python shell. Use edit > select all and copy everything that outputs. Paste it into notepad and save the file as test.htm to the desktop. Open this file and you will see a logged in neopets page hurrah! Everything is functioning as it should.

    Note – In the above we used the get http function to get a pages source code , then printed the html output. We then saved the html output to a file to debug it. More on get/post next lesson!
    Attached Files Attached Files
    Last edited by DarkByte; 03-20-2014 at 09:39 AM.

  2. BuyNeopointsCheap

  3. The Following 14 Users Say Thank You to DarkByte For This Useful Post:

    ~Domenick~ (07-27-2014),Arsura (01-27-2014),Ban (01-28-2014),donovanrules1234 (04-07-2015),EdenQueen (03-02-2014),Ghosts (08-02-2014),hectorvazc (06-29-2014),Infamous Joe (01-25-2014),mt5o5bd (02-04-2014),soujen (10-08-2015),User5931 (06-03-2015),Water (10-02-2014),Whispers (01-25-2014),Zeus (03-07-2015)

  4. #2
    User5931's Avatar
    Join Date
    May 2015
    Thanked 19 Times in 14 Posts

    2 Post(s)
    Time Online
    1 d 6 h 33 m
    Avg. Time Online
    3 m
    Rep Power
    Total noob and out of my depth, but is there some way we can spoof a useragent or incorporate use of a proxy?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts