DDG: strip ads better + skip zeroclick info

From: 625ef777cd
This commit is contained in:
James Lu 2014-12-11 07:47:58 -08:00 committed by GLolol
parent 5d0de2d44e
commit f8d5afbb46
1 changed files with 7 additions and 6 deletions

View File

@ -75,13 +75,14 @@ class DDG(callbacks.Plugin):
# up of 3 <tr> tags:
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:
# Sometimes there will be another table for page navigation.
webresults = tables[2].find_all('tr')
webresults = tables[1].find_all('tr')
if webresults:
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:]
except KeyError: pass
# 1) The link and title.