Moved fact.py over to BS4 (I need to rewrite fact.py soon, it's a bit outdated and somewhat broken), removed old htmlstipper library

This commit is contained in:
Luke Rogers 2012-09-04 09:58:59 +12:00
parent b536bbf754
commit 16573eb482
2 changed files with 5 additions and 49 deletions

View file

@ -1,8 +1,6 @@
import re
from util import hook
from util import http
from util import misc
from BeautifulSoup import BeautifulSoup
from util import hook, http
from bs4 import BeautifulSoup
@hook.command(autohelp=False)
@ -22,10 +20,10 @@ def fact(inp, say=False, nick=False):
def get_fact():
page = http.get('http://www.omg-facts.com/random')
soup = BeautifulSoup(page)
container = soup.find('a', {'class': 'surprise'})
link = container['href']
response = soup.find('a', {'class': 'surprise'})
link = response['href']
fact = misc.strip_html(container.renderContents())
fact = response.contents[0]
if fact:
return (fact, link)