From accf84401fdf7b65a9f58705449137ff701b55a5 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 5 Sep 2012 11:09:54 +1200 Subject: [PATCH] Forgot to add this -.- --- plugins/fact.py | 2 -- plugins/util/http.py | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/fact.py b/plugins/fact.py index 549175d..eb427ea 100755 --- a/plugins/fact.py +++ b/plugins/fact.py @@ -19,11 +19,9 @@ def fact(inp, say=False, nick=False): response = soup.find('a', {'class': 'surprise'}) link = response['href'] - #fact = response.contents[0] fact = ''.join(response.find(text=True)) if fact: - print fact fact = http.unescape(fact.decode("utf-8")).strip() break else: diff --git a/plugins/util/http.py b/plugins/util/http.py index a91a5f6..7131487 100755 --- a/plugins/util/http.py +++ b/plugins/util/http.py @@ -9,6 +9,7 @@ import urlparse from urllib import quote, quote_plus as _quote_plus from lxml import etree, html +from bs4 import BeautifulSoup # used in plugins that import this from urllib2 import URLError, HTTPError @@ -35,6 +36,10 @@ def get_html(*args, **kwargs): return html.fromstring(get(*args, **kwargs)) +def get_soup(*args, **kwargs): + return BeautifulSoup(get(*args, **kwargs), 'lxml') + + def get_xml(*args, **kwargs): return etree.fromstring(get(*args, **kwargs))