Skip to content

Instantly share code, notes, and snippets.

Created October 19, 2013 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7051718 to your computer and use it in GitHub Desktop.
Save anonymous/7051718 to your computer and use it in GitHub Desktop.
/u/mdadmfan's raop hax
import datetime as dt
import json
import random
import re
import requests as req
today = dt.datetime.today()
# these users were validated by hand
extraEntries = ["could be you"]
commentsReq = req.get("http://www.reddit.com/r/Random_Acts_Of_Pizza/comments/1ordny/content_random_pizza.json")
comments = json.loads(commentsReq.text)[1]["data"]["children"]
entries = dict()
for comment in comments:
comment = comment["data"]
if re.match("(?i).*random pizza.*",comment["body"]) and "reddit_status" not in comment["author"]:
user = json.loads(req.get("http://www.reddit.com/user/" + comment["author"] + "/about.json").text)["data"]
age_in_days = (today - dt.datetime.fromtimestamp(user["created"])).days
print "%-20s\t%-7s\t%s" % (str(comment["author"]),str(user["has_verified_email"]),str(age_in_days))
if user["has_verified_email"] and age_in_days > 31:
entries[str(comment["author"])] = 0
listEntries = list(entries)
listEntries = listEntries + extraEntries
print "Entries: " + str(listEntries)
print "Winner: " + str(random.choice(listEntries))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment