Skip to content

Instantly share code, notes, and snippets.

@pberry
Created March 8, 2011 15:58
Show Gist options
  • Save pberry/860438 to your computer and use it in GitHub Desktop.
Save pberry/860438 to your computer and use it in GitHub Desktop.
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