diff options
author | Adam Tauber <asciimoo@gmail.com> | 2020-01-02 22:28:47 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2020-01-02 22:28:47 +0100 |
commit | 2292e6e130dca104cb324197b63611a012e4ef3c (patch) | |
tree | 45c5d751931f830dc9091c4ec9e4a99649db506d /searx | |
parent | a1b85571a25d67b752bf6072255b928866be9c4f (diff) | |
download | searxng-2292e6e130dca104cb324197b63611a012e4ef3c.tar.gz searxng-2292e6e130dca104cb324197b63611a012e4ef3c.zip |
[fix] handle missing result size
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/bing.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py index ed0b87dbd..24776c400 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -63,6 +63,8 @@ def response(resp): results = [] result_len = 0 + + dom = html.fromstring(resp.text) # parse results for result in eval_xpath(dom, '//div[@class="sa_cc"]'): @@ -89,8 +91,7 @@ def response(resp): 'content': content}) try: - result_len_container = "".join(eval_xpath(dom, '//span[@class="sb_count"]/text()')) - result_len_container = utils.to_string(result_len_container) + result_len_container = "".join(eval_xpath(dom, '//span[@class="sb_count"]//text()')) if "-" in result_len_container: # Remove the part "from-to" for paginated request ... result_len_container = result_len_container[result_len_container.find("-") * 2 + 2:] @@ -102,7 +103,7 @@ def response(resp): logger.debug('result error :\n%s', e) pass - if _get_offset_from_pageno(resp.search_params.get("pageno", 0)) > result_len: + if result_len and _get_offset_from_pageno(resp.search_params.get("pageno", 0)) > result_len: return [] results.append({'number_of_results': result_len}) |