diff options
author | David A Roberts <d@vidr.cc> | 2017-01-17 21:14:33 +1000 |
---|---|---|
committer | David A Roberts <d@vidr.cc> | 2017-01-17 21:14:33 +1000 |
commit | 7492997c517a447b2163abbd800cfd4b84dcf77d (patch) | |
tree | 12d3aa40e11788e6f8c8d1feb8496f7d2ed2e11d /searx/engines/xpath.py | |
parent | 1a9f8240b851c64a10be7b8990b6f3926ca506b3 (diff) | |
download | searxng-7492997c517a447b2163abbd800cfd4b84dcf77d.tar.gz searxng-7492997c517a447b2163abbd800cfd4b84dcf77d.zip |
[fix] allow empty content
Diffstat (limited to 'searx/engines/xpath.py')
-rw-r--r-- | searx/engines/xpath.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/searx/engines/xpath.py b/searx/engines/xpath.py index 18943bba4..0d39b28a8 100644 --- a/searx/engines/xpath.py +++ b/searx/engines/xpath.py @@ -31,8 +31,6 @@ if xpath_results is a string element, then it's already done def extract_text(xpath_results): if type(xpath_results) == list: # it's list of result : concat everything using recursive call - if not xpath_results: - raise Exception('Empty url resultset') result = '' for e in xpath_results: result = result + extract_text(e) @@ -48,6 +46,8 @@ def extract_text(xpath_results): def extract_url(xpath_results, search_url): + if xpath_results == []: + raise Exception('Empty url resultset') url = extract_text(xpath_results) if url.startswith('//'): @@ -103,8 +103,8 @@ def response(resp): if results_xpath: for result in dom.xpath(results_xpath): url = extract_url(result.xpath(url_xpath), search_url) - title = extract_text(result.xpath(title_xpath)[0]) - content = extract_text(result.xpath(content_xpath)[0]) + title = extract_text(result.xpath(title_xpath)) + content = extract_text(result.xpath(content_xpath)) results.append({'url': url, 'title': title, 'content': content}) else: for url, title, content in zip( |