From 272ba283e9e39c3795fb1c875c66f31f0a43f260 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 2 Aug 2013 00:16:16 +1200 Subject: [PATCH] Added the neat Horoscope plugin by @infinitylabs from infinitylabs/UguuBot --- plugins/horoscope.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/horoscope.py diff --git a/plugins/horoscope.py b/plugins/horoscope.py new file mode 100644 index 0000000..d683f39 --- /dev/null +++ b/plugins/horoscope.py @@ -0,0 +1,21 @@ +# Plugin by Infinity - + +from util import hook, http + +@hook.command +def horoscope(inp): + "horoscope -- Get your horoscope." + + url = "http://my.horoscope.com/astrology/free-daily-horoscope-%s.html" % inp + soup = http.get_soup(url) + + title = soup.find_all('h1', {'class': 'h1b'})[1] + horoscope = soup.find('div', {'class': 'fontdef1'}) + result = "\x02%s\x02 %s" % (title, horoscope) + result = http.strip_html(result) + #result = unicode(result, "utf8").replace('flight ','') + + if not title: + return "Could not get the horoscope for %s." % inp + + return result \ No newline at end of file