First :D
This commit is contained in:
commit
37588421f3
100 changed files with 22673 additions and 0 deletions
24
plugins/fmylife.py
Normal file
24
plugins/fmylife.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
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)
|
Reference in a new issue