on master help sign in
[fix] skip non-complete google news results
commit108392f8daf70fbfcd43e9d691d665aad1e15994 authorAdam Tauber <asciimoo@gmail.com> dateTue 10 Jan 2017, 11:03 (10 years ago) parent94327d6
1 file changed+8−5
searx/engines/google_news.py+8−5
searx/engines/google_news.py+8−5
@@ -66,11 +66,14 @@ def response(resp):
6666
6767 # parse results
6868 for result in dom.xpath('//div[@class="g"]|//div[@class="g _cy"]'):
69− r = {
70− 'url': result.xpath('.//div[@class="_cnc"]//a/@href')[0],
71− 'title': ''.join(result.xpath('.//div[@class="_cnc"]//h3//text()')),
72− 'content': ''.join(result.xpath('.//div[@class="st"]//text()')),
73− }
69+ try:
70+ r = {
71+ 'url': result.xpath('.//div[@class="_cnc"]//a/@href')[0],
72+ 'title': ''.join(result.xpath('.//div[@class="_cnc"]//h3//text()')),
73+ 'content': ''.join(result.xpath('.//div[@class="st"]//text()')),
74+ }
75+ except:
76+ continue
7477
7578 imgs = result.xpath('.//img/@src')
7679 if len(imgs) and not imgs[0].startswith('data'):