This forum is in archive mode. You will not be able to post new content.

Author Topic: [Python] EZ Reputation Grabber  (Read 609 times)

0 Members and 1 Guest are viewing this topic.

Offline theifyppl

  • Serf
  • *
  • Posts: 44
  • Cookies: 20
    • View Profile
[Python] EZ Reputation Grabber
« on: July 01, 2013, 10:36:49 PM »
Hey EZ,

I was bored today and thought of the idea to code an EZ reputation checker.  Basically, you enter in your user ID, which can be found in the URL of your profile page after clicking on your name anywhere in the forums.  The link will look like: http://evilzone.org/profile/?u=[your user id]

After you enter that in, it checks your current reputation and displays it.  Then, it checks your rep again every 5 minutes and displays it if it has changed since the last time you checked.  Basically this just gave me some practice with httplib2.  I wanted to incorporate a Qt Message Box or something, but I'll do that later.  Here's the code:

Code: (python) [Select]
#!/usr/bin/env python3

import httplib2
import re
import time

httpObject = httplib2.Http(".cache")

def lookUpRep(uID):
    URL = "http://evilzone.org/profile/?u=" + str(uID)
    response, content = httpObject.request(URL, headers={'cache-control':'no-cache'})
    contentString = content.decode('utf-8')
    x = re.search(r"\+[0-9]{1,4}", contentString)
    if x:
        rep = x.group(0)
        return rep
    else:
        return False
       
if __name__ == '__main__':
    userID = input("Please enter a valid EvilZone User ID: ")
    currentRep = lookUpRep(int(userID))
    if currentRep != False:
        print("Your current rep is: ", currentRep)
        print("I will notify you when it changes...")
        while 1:
            time.sleep(300)
            newRep = lookUpRep(int(userID))
            if newRep != currentRep:
                print("Rep has changed!")
                print("New rep: ", newRep)
                currentRep = newRep
    else:
        print("You entered an incorrect user ID.")

I'll edit it a bit later to put proper docstrings in and what not.
« Last Edit: July 01, 2013, 10:37:17 PM by theifyppl »

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.