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:
#!/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.