mirror of
https://github.com/searxng/searxng.git
synced 2024-12-04 08:26:28 +00:00
[fix] allow empty content
This commit is contained in:
parent
1a9f8240b8
commit
7492997c51
1 changed files with 4 additions and 4 deletions
|
@ -31,8 +31,6 @@ if xpath_results is a string element, then it's already done
|
||||||
def extract_text(xpath_results):
|
def extract_text(xpath_results):
|
||||||
if type(xpath_results) == list:
|
if type(xpath_results) == list:
|
||||||
# it's list of result : concat everything using recursive call
|
# it's list of result : concat everything using recursive call
|
||||||
if not xpath_results:
|
|
||||||
raise Exception('Empty url resultset')
|
|
||||||
result = ''
|
result = ''
|
||||||
for e in xpath_results:
|
for e in xpath_results:
|
||||||
result = result + extract_text(e)
|
result = result + extract_text(e)
|
||||||
|
@ -48,6 +46,8 @@ def extract_text(xpath_results):
|
||||||
|
|
||||||
|
|
||||||
def extract_url(xpath_results, search_url):
|
def extract_url(xpath_results, search_url):
|
||||||
|
if xpath_results == []:
|
||||||
|
raise Exception('Empty url resultset')
|
||||||
url = extract_text(xpath_results)
|
url = extract_text(xpath_results)
|
||||||
|
|
||||||
if url.startswith('//'):
|
if url.startswith('//'):
|
||||||
|
@ -103,8 +103,8 @@ def response(resp):
|
||||||
if results_xpath:
|
if results_xpath:
|
||||||
for result in dom.xpath(results_xpath):
|
for result in dom.xpath(results_xpath):
|
||||||
url = extract_url(result.xpath(url_xpath), search_url)
|
url = extract_url(result.xpath(url_xpath), search_url)
|
||||||
title = extract_text(result.xpath(title_xpath)[0])
|
title = extract_text(result.xpath(title_xpath))
|
||||||
content = extract_text(result.xpath(content_xpath)[0])
|
content = extract_text(result.xpath(content_xpath))
|
||||||
results.append({'url': url, 'title': title, 'content': content})
|
results.append({'url': url, 'title': title, 'content': content})
|
||||||
else:
|
else:
|
||||||
for url, title, content in zip(
|
for url, title, content in zip(
|
||||||
|
|
Loading…
Reference in a new issue