From 1ca04b6b3e7bda4336488b08960473db80a8958e Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 23 Apr 2012 11:58:19 +1200 Subject: [PATCH] Random tweaks --- plugins/fmylife.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/fmylife.py b/plugins/fmylife.py index 2cbc553..d49ef60 100755 --- a/plugins/fmylife.py +++ b/plugins/fmylife.py @@ -1,24 +1,23 @@ # Plugin by Lukeroge from util import hook, http -from urlparse import urljoin from BeautifulSoup import BeautifulSoup from collections import defaultdict -base_url = 'http://www.fmylife.com/' - fml_cache = defaultdict() def refresh_cache(): """ gets a page of random FMLs and puts them into a dictionary """ - page = http.get(urljoin(base_url, 'random')) + page = http.get('http://www.fmylife.com/random/') soup = BeautifulSoup(page) for e in soup.findAll('div', {'class': 'post article'}): id = int(e['id']) + # get the text of the FML text = ''.join(e.find('p').findAll(text=True)) text = http.unescape(text) + # append to the dictionary fml_cache[id] = text # do an initial refresh of the cache