add koran scraping, courtesy GhettoWizard
This commit is contained in:
parent
62cc0490d1
commit
a21f27e64e
|
@ -1,5 +1,7 @@
|
|||
import urllib
|
||||
|
||||
from lxml import html
|
||||
|
||||
from util import hook
|
||||
|
||||
|
||||
|
@ -25,3 +27,24 @@ def bible(inp):
|
|||
text = text[:text.rfind(' ', 0, 400)] + '...'
|
||||
|
||||
return text
|
||||
|
||||
## Koran look-up plugin by Ghetto Wizard
|
||||
|
||||
@hook.command('allah')
|
||||
@hook.command
|
||||
def koran(inp):
|
||||
".koran <chapter.verse> -- gets <chapter.verse> from the Koran"
|
||||
|
||||
if not inp:
|
||||
return koran.__doc__
|
||||
|
||||
base_url = 'http://quod.lib.umich.edu/cgi/k/koran/koran-idx?type=simple&q1='
|
||||
|
||||
raw_data = urllib.urlopen(base_url + urllib.quote(inp, '')).read()
|
||||
|
||||
results = html.fromstring(raw_data).xpath('//li')
|
||||
|
||||
if not results:
|
||||
return 'No results for ' + inp
|
||||
|
||||
return results[0].text_content()
|
Loading…
Reference in New Issue