import datetime
import urllib
def get_tagthenet_url_for_todays_wikipedia_page():
now = datetime.datetime.now()
day = now.day
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
month = months[now.month - 1]
url = 'http://tagthe.net/api/?url=http://en.wikipedia.org/wiki/%s_%s&view=json' % (month, day)
return url
def get_people():
"""Returns the names of people found on a web page"""
url = get_tagthenet_url_for_todays_wikipedia_page()
w = urllib.urlopen(url)
ttn = w.read()
w.close()
start_string = '"person":['
start_index = ttn.find(start_string) + len(start_string)
stop_index = ttn[start_index:].find(']') + start_index
people_str = ttn[start_index: stop_index]
people_str = people_str.replace('"', '')
people = people_str.split(',')
return people
w = 1920
h = 1200
size(w, h)
people = get_people()
font('Arial Black')
white = color(1,1,1)
black = color(0,0,0)
red = color(1,0,0)
translate((w//4),(h//4))
for i in range(50):
translate(random(-100, 100), random(-100, 100))
push()
rotate(random(5)*45)
fontsize(random(200))
fill(choice((white,black,red)))
someText = choice(people)
if random(2) == 1:
someText = someText.lower()
try:
text(someText, 0, 0)
except:
pass
pop()