Created
March 8, 2011 15:58
-
-
Save pberry/860438 to your computer and use it in GitHub Desktop.
This file contains 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
def penny(self, irc, msg, args): | |
html = urlopen("http://www.penny-arcade.com/archive/").read() | |
soup = BeautifulSoup(html) | |
tagcloud = soup.find("ul","tagcloud") | |
tags = [] | |
for tag in tagcloud.findAll('li'): | |
tags.append(tag.a.string) | |
mytag = tags[randint(0, len(tags))] | |
search = urlopen("http://www.penny-arcade.com/archive/?q=" + mytag).read() | |
comiclist = BeautifulSoup(search) | |
comics = comiclist.findAll("td","content_title") | |
links = [] | |
for td in comics: | |
print td.a['href'] | |
links.append(td.a['href']) | |
comic = links[randint(0, len(links))] | |
irc.reply("http://www.penny-arcade.com" + comic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment