diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2017-01-10 11:03:05 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2017-01-10 11:03:05 +0100 |
| commit | 108392f8daf70fbfcd43e9d691d665aad1e15994 (patch) | |
| tree | 22069c46acdb6008e6cfad711abd51d93d78c073 | |
| parent | 94327d67fcc8b7891556bee030432677a4692f45 (diff) | |
[fix] skip non-complete google news results
| -rw-r--r-- | searx/engines/google_news.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py index 49c6a5d50..6b79ff5c8 100644 --- a/searx/engines/google_news.py +++ b/searx/engines/google_news.py @@ -66,11 +66,14 @@ def response(resp): # parse results for result in dom.xpath('//div[@class="g"]|//div[@class="g _cy"]'): - r = { - 'url': result.xpath('.//div[@class="_cnc"]//a/@href')[0], - 'title': ''.join(result.xpath('.//div[@class="_cnc"]//h3//text()')), - 'content': ''.join(result.xpath('.//div[@class="st"]//text()')), - } + try: + r = { + 'url': result.xpath('.//div[@class="_cnc"]//a/@href')[0], + 'title': ''.join(result.xpath('.//div[@class="_cnc"]//h3//text()')), + 'content': ''.join(result.xpath('.//div[@class="st"]//text()')), + } + except: + continue imgs = result.xpath('.//img/@src') if len(imgs) and not imgs[0].startswith('data'): |