mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
[enh] use format to concatenate strings
This commit is contained in:
parent
3e3672e079
commit
5278fa666c
@ -48,14 +48,16 @@ def response(resp):
|
|||||||
|
|
||||||
url = entry.xpath('.//id')[0].text
|
url = entry.xpath('.//id')[0].text
|
||||||
|
|
||||||
content = entry.xpath('.//summary')[0].text
|
content_string = '{doi_content}{abstract_content}'
|
||||||
|
|
||||||
|
abstract = entry.xpath('.//summary')[0].text
|
||||||
|
|
||||||
# If a doi is available, add it to the snipppet
|
# If a doi is available, add it to the snipppet
|
||||||
try:
|
try:
|
||||||
doi = entry.xpath('.//link[@title="doi"]')[0].text
|
doi_content = entry.xpath('.//link[@title="doi"]')[0].text
|
||||||
content = 'DOI: ' + doi + ' Abstract: ' + content
|
content = content_string.format(doi_content=doi_content, abstract_content=abstract_content)
|
||||||
except:
|
except:
|
||||||
pass
|
content = content_string.format(abstract_content=abstract_content)
|
||||||
|
|
||||||
if len(content) > 300:
|
if len(content) > 300:
|
||||||
content = content[0:300] + "..."
|
content = content[0:300] + "..."
|
||||||
|
Loading…
Reference in New Issue
Block a user