Created
July 5, 2011 17:53
-
-
Save sallysmith1337/1065409 to your computer and use it in GitHub Desktop.
Fortune cookie message getter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Fortune Cookie Saying Grabber | |
# By James Penguin ([email protected]) | |
# | |
import BeautifulSoup | |
import urllib2 | |
def get_fortune(): | |
try: | |
page = urllib2.urlopen("http://www.fortunecookiemessage.com/") | |
except: | |
return "No fortune for you." | |
soup = BeautifulSoup.BeautifulSoup(page) | |
for tag in soup.findAll("a"): | |
if not tag.has_key("href") or not tag["href"].startswith("cookie"): | |
continue | |
if not len(tag.contents): | |
return "No fortune for you." | |
return tag.contents[0] | |
return "No fortune for you." | |
if __name__ == '__main__': | |
print get_fortune() |
:| but does it go to my cell phone?
:(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah son!