mirror of https://github.com/searxng/searxng.git
[fix] incorrect URLs in Reddit results - closes #538
This commit is contained in:
parent
2661c3ab21
commit
4eeb5fb76b
|
@ -13,7 +13,7 @@
|
||||||
import json
|
import json
|
||||||
from cgi import escape
|
from cgi import escape
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse, urljoin
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
|
@ -21,7 +21,8 @@ categories = ['general', 'images', 'news', 'social media']
|
||||||
page_size = 25
|
page_size = 25
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
search_url = 'https://www.reddit.com/search.json?{query}'
|
base_url = 'https://www.reddit.com/'
|
||||||
|
search_url = base_url + 'search.json?{query}'
|
||||||
|
|
||||||
|
|
||||||
# do search-request
|
# do search-request
|
||||||
|
@ -52,7 +53,7 @@ def response(resp):
|
||||||
|
|
||||||
# extract post information
|
# extract post information
|
||||||
params = {
|
params = {
|
||||||
'url': data['url'],
|
'url': urljoin(base_url, data['permalink']),
|
||||||
'title': data['title']
|
'title': data['title']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ def response(resp):
|
||||||
url_info = urlparse(thumbnail)
|
url_info = urlparse(thumbnail)
|
||||||
# netloc & path
|
# netloc & path
|
||||||
if url_info[1] != '' and url_info[2] != '':
|
if url_info[1] != '' and url_info[2] != '':
|
||||||
|
params['img_src'] = data['url']
|
||||||
params['thumbnail_src'] = thumbnail
|
params['thumbnail_src'] = thumbnail
|
||||||
params['template'] = 'images.html'
|
params['template'] = 'images.html'
|
||||||
img_results.append(params)
|
img_results.append(params)
|
||||||
|
|
Loading…
Reference in New Issue