mirror of
https://github.com/searxng/searxng.git
synced 2025-07-24 13:49:26 +02:00
[mod] add/modify image fetching for bing_news, qwant and twitter engines
This commit is contained in:
parent
4cffd78650
commit
f5128c7cb9
4 changed files with 28 additions and 11 deletions
|
@ -27,6 +27,7 @@ search_url = base_url + 'search?'
|
|||
|
||||
# specific xpath variables
|
||||
results_xpath = '//li[@data-item-type="tweet"]'
|
||||
avatar_xpath = './/img[contains(@class, "avatar")]/@src'
|
||||
link_xpath = './/small[@class="time"]//a'
|
||||
title_xpath = './/span[contains(@class, "username")]'
|
||||
content_xpath = './/p[contains(@class, "tweet-text")]'
|
||||
|
@ -57,6 +58,8 @@ def response(resp):
|
|||
try:
|
||||
link = tweet.xpath(link_xpath)[0]
|
||||
content = extract_text(tweet.xpath(content_xpath)[0])
|
||||
img_src = tweet.xpath(avatar_xpath)[0]
|
||||
img_src = img_src.replace('_bigger', '_normal')
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
|
@ -71,12 +74,14 @@ def response(resp):
|
|||
results.append({'url': url,
|
||||
'title': title,
|
||||
'content': content,
|
||||
'img_src': img_src,
|
||||
'publishedDate': publishedDate})
|
||||
else:
|
||||
# append result
|
||||
results.append({'url': url,
|
||||
'title': title,
|
||||
'content': content})
|
||||
'content': content,
|
||||
'img_src': img_src})
|
||||
|
||||
# return results
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue