mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-09 11:04:07 +01:00
parent
5d0de2d44e
commit
f8d5afbb46
13
plugin.py
13
plugin.py
@ -56,7 +56,7 @@ except ImportError:
|
|||||||
class DDG(callbacks.Plugin):
|
class DDG(callbacks.Plugin):
|
||||||
"""Searches for results on DuckDuckGo."""
|
"""Searches for results on DuckDuckGo."""
|
||||||
threaded = True
|
threaded = True
|
||||||
|
|
||||||
def search(self, irc, msg, args, text):
|
def search(self, irc, msg, args, text):
|
||||||
"""<query>
|
"""<query>
|
||||||
|
|
||||||
@ -74,14 +74,15 @@ class DDG(callbacks.Plugin):
|
|||||||
# DuckDuckGo lite uses tables for everything. Each WEB result is made
|
# DuckDuckGo lite uses tables for everything. Each WEB result is made
|
||||||
# up of 3 <tr> tags:
|
# up of 3 <tr> tags:
|
||||||
tables = soup.find_all('table')
|
tables = soup.find_all('table')
|
||||||
|
|
||||||
webresults = tables[1].find_all('tr')
|
# Sometimes there is an extra table for page navigation
|
||||||
|
webresults = tables[2].find_all('tr')
|
||||||
if not webresults:
|
if not webresults:
|
||||||
# Sometimes there will be another table for page navigation.
|
webresults = tables[1].find_all('tr')
|
||||||
webresults = tables[2].find_all('tr')
|
|
||||||
if webresults:
|
if webresults:
|
||||||
try:
|
try:
|
||||||
if 'result-sponsored' in webresults[0]["class"]:
|
while 'result-sponsored' in webresults[0]["class"]:
|
||||||
|
self.log.debug("DDG: stripping 1 sponsored/ad result.")
|
||||||
webresults = webresults[4:]
|
webresults = webresults[4:]
|
||||||
except KeyError: pass
|
except KeyError: pass
|
||||||
# 1) The link and title.
|
# 1) The link and title.
|
||||||
|
Loading…
Reference in New Issue
Block a user