summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-04-16 13:29:12 +0200
committerAdam Tauber <asciimoo@gmail.com>2016-04-16 13:29:12 +0200
commit817c74e52317126128c6f8740df01b8bdc51c3cf (patch)
tree8df600014776da58cfa986d7ab1933e7cf9cb902 /searx
parent2661c3ab2140603a254d37d2709fee342026fe7b (diff)
parentd98024c26eb4f3e45643a2d2d8124a0616f863e1 (diff)
Merge pull request #542 from ukwt/fix538
[fix] incorrect URLs in Reddit image search results - closes #538
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/reddit.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/searx/engines/reddit.py b/searx/engines/reddit.py
index 9729898e5..3ca7e44f6 100644
--- a/searx/engines/reddit.py
+++ b/searx/engines/reddit.py
@@ -13,7 +13,7 @@
import json
from cgi import escape
from urllib import urlencode
-from urlparse import urlparse
+from urlparse import urlparse, urljoin
from datetime import datetime
# engine dependent config
@@ -21,7 +21,8 @@ categories = ['general', 'images', 'news', 'social media']
page_size = 25
# 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
@@ -52,7 +53,7 @@ def response(resp):
# extract post information
params = {
- 'url': data['url'],
+ 'url': urljoin(base_url, data['permalink']),
'title': data['title']
}
@@ -61,6 +62,7 @@ def response(resp):
url_info = urlparse(thumbnail)
# netloc & path
if url_info[1] != '' and url_info[2] != '':
+ params['img_src'] = data['url']
params['thumbnail_src'] = thumbnail
params['template'] = 'images.html'
img_results.append(params)