diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2016-06-28 00:06:50 +0200 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2016-06-28 00:06:50 +0200 |
| commit | 2f7752b410c449aac463c248c0b7e41f69b6b07b (patch) | |
| tree | cf39c310166874a1b3c8fb28a3e925e969794429 /searx/engines | |
| parent | 36c8977390b50259de56cc9678499340c78ee25b (diff) | |
[enh] display number of results
Diffstat (limited to 'searx/engines')
| -rw-r--r-- | searx/engines/bing.py | 10 | ||||
| -rw-r--r-- | searx/engines/yahoo.py | 7 |
2 files changed, 13 insertions, 4 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py index 171606cf6..6bdfd378b 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -54,6 +54,12 @@ def response(resp): dom = html.fromstring(resp.text) + try: + results.append({'number_of_results': int(dom.xpath('//span[@class="sb_count"]/text()')[0] + .split()[0].replace(',', ''))}) + except: + pass + # parse results for result in dom.xpath('//div[@class="sa_cc"]'): link = result.xpath('.//h3/a')[0] @@ -66,10 +72,6 @@ def response(resp): 'title': title, 'content': content}) - # return results if something is found - if results: - return results - # parse results again if nothing is found yet for result in dom.xpath('//li[@class="b_algo"]'): link = result.xpath('.//h2/a')[0] diff --git a/searx/engines/yahoo.py b/searx/engines/yahoo.py index 769e7e47f..b8b40e4aa 100644 --- a/searx/engines/yahoo.py +++ b/searx/engines/yahoo.py @@ -77,6 +77,13 @@ def response(resp): dom = html.fromstring(resp.text) + try: + results_num = int(dom.xpath('//div[@class="compPagination"]/span[last()]/text()')[0] + .split()[0].replace(',', '')) + results.append({'number_of_results': results_num}) + except: + pass + # parse results for result in dom.xpath(results_xpath): try: |