mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-19 23:20:57 +01:00
parent
30615a7284
commit
48b5016f41
10
plugin.py
10
plugin.py
@ -81,6 +81,7 @@ class DDG(callbacks.Plugin):
|
|||||||
# settings given to the function directly.
|
# settings given to the function directly.
|
||||||
show_snippet = self.registryValue("showSnippet", channel_context)
|
show_snippet = self.registryValue("showSnippet", channel_context)
|
||||||
maxr = max_results or self.registryValue("maxResults", channel_context)
|
maxr = max_results or self.registryValue("maxResults", channel_context)
|
||||||
|
self.log.debug('DDG: got %s for max results', maxr)
|
||||||
|
|
||||||
# In a nutshell, the 'lite' site puts all of its usable content
|
# In a nutshell, the 'lite' site puts all of its usable content
|
||||||
# into tables. This means that headings, result snippets and
|
# into tables. This means that headings, result snippets and
|
||||||
@ -88,13 +89,12 @@ class DDG(callbacks.Plugin):
|
|||||||
# parsing somewhat tricky.
|
# parsing somewhat tricky.
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
for t in self._ddgurl(text):
|
raw_results = self._ddgurl(text)
|
||||||
# We run a for loop here to extract meaningful content:
|
for t in raw_results:
|
||||||
for n in range(1, maxr):
|
|
||||||
res = ''
|
res = ''
|
||||||
# Each valid result has a preceding heading in the format
|
# Each valid result has a preceding heading in the format
|
||||||
# '<td valign="top">1. </td>', etc.
|
# '<td valign="top">1. </td>', etc.
|
||||||
if ("%s." % n) in t.text:
|
if t.text[0].isdigit():
|
||||||
res = t.next_sibling.next_sibling
|
res = t.next_sibling.next_sibling
|
||||||
if not res:
|
if not res:
|
||||||
continue
|
continue
|
||||||
@ -131,7 +131,7 @@ class DDG(callbacks.Plugin):
|
|||||||
results.append(s)
|
results.append(s)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
return results
|
return results[:maxr]
|
||||||
|
|
||||||
@wrap(['text'])
|
@wrap(['text'])
|
||||||
def search(self, irc, msg, args, text):
|
def search(self, irc, msg, args, text):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user