Merge pull request #3367 from br4nnigan/master

allow engines to override pretty_url and use this in bing to show mea…
This commit is contained in:
Adam Tauber 2022-09-29 20:50:33 +00:00 committed by GitHub
commit 31eef5b9db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -68,11 +68,13 @@ def response(resp):
for result in eval_xpath(dom, '//div[@class="sa_cc"]'):
link = eval_xpath(result, './/h3/a')[0]
url = link.attrib.get('href')
pretty_url = extract_text(eval_xpath(result, './/cite'))
title = extract_text(link)
content = extract_text(eval_xpath(result, './/p'))
# append result
results.append({'url': url,
'pretty_url': pretty_url,
'title': title,
'content': content})

View File

@ -647,7 +647,7 @@ def search():
# removing html content and whitespace duplications
result['title'] = ' '.join(html_to_text(result['title']).strip().split())
if 'url' in result:
if 'url' in result and !('pretty_url' in result):
result['pretty_url'] = prettify_url(result['url'])
# TODO, check if timezone is calculated right