mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-02 16:31:11 -05:00
DDG: rewrite to fix "max results" not working
This commit is contained in:
parent
47bb74d7d9
commit
7a6e2f9f97
@ -81,6 +81,7 @@ class DDG(callbacks.Plugin):
|
||||
# settings given to the function directly.
|
||||
show_snippet = self.registryValue("showSnippet", 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
|
||||
# into tables. This means that headings, result snippets and
|
||||
@ -88,13 +89,12 @@ class DDG(callbacks.Plugin):
|
||||
# parsing somewhat tricky.
|
||||
results = []
|
||||
|
||||
for t in self._ddgurl(text):
|
||||
# We run a for loop here to extract meaningful content:
|
||||
for n in range(1, maxr):
|
||||
raw_results = self._ddgurl(text)
|
||||
for t in raw_results:
|
||||
res = ''
|
||||
# Each valid result has a preceding heading in the format
|
||||
# '<td valign="top">1. </td>', etc.
|
||||
if ("%s." % n) in t.text:
|
||||
if t.text[0].isdigit():
|
||||
res = t.next_sibling.next_sibling
|
||||
if not res:
|
||||
continue
|
||||
@ -131,7 +131,7 @@ class DDG(callbacks.Plugin):
|
||||
results.append(s)
|
||||
except AttributeError:
|
||||
continue
|
||||
return results
|
||||
return results[:maxr]
|
||||
|
||||
@wrap(['text'])
|
||||
def search(self, irc, msg, args, text):
|
||||
|
Loading…
x
Reference in New Issue
Block a user