Cleaning up.

This commit is contained in:
Luke Rogers 2012-02-03 02:15:06 +13:00
parent 25ffcd44be
commit 4ebaba1746
3 changed files with 0 additions and 218 deletions

View file

@ -1,24 +0,0 @@
import re
from util import hook, http, misc
from urlparse import urljoin
from BeautifulSoup import BeautifulSoup
base_url = 'http://www.fmylife.com/'
rand_url = urljoin(base_url, 'random')
spec_url = urljoin(base_url, '%d')
error = 'Today I couldn\'t seem to access fmylife.com.. FML'
@hook.command(autohelp=False)
@hook.command("fml")
def fmylife(inp):
page = http.get(rand_url)
soup = BeautifulSoup(page)
soup.find('div', id='submit').extract()
post = soup.body.find('div', 'post')
id = int(post.find('a', 'fmllink')['href'].split('/')[-1])
body = strip_html(decode(' '.join(link.renderContents() for link in post('a', 'fmllink')), 'utf-8'))
return u'%s: (%d) %s' % (nick, id, body)