commit: 610117d054dd4740988b12fa8156a7781f76daf4
parent: 20d2d4dab1edab77634184d7932b380a549ca3a3
Author: Adam Tauber <asciimoo@gmail.com>
Date: Wed, 30 Aug 2017 21:35:12 +0200
Merge pull request #1015 from misnyo/digg
[fix] digg now requires cookie for search
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/searx/engines/digg.py b/searx/engines/digg.py
@@ -10,6 +10,8 @@
@parse url, title, content, publishedDate, thumbnail
"""
+import random
+import string
from dateutil import parser
from json import loads
from lxml import html
@@ -30,12 +32,17 @@ title_xpath = './/h2//a//text()'
content_xpath = './/p//text()'
pubdate_xpath = './/time'
+digg_cookie_chars = string.ascii_uppercase + string.ascii_lowercase +\
+ string.digits + "+_"
+
# do search-request
def request(query, params):
offset = (params['pageno'] - 1) * 10
params['url'] = search_url.format(position=offset,
query=quote_plus(query))
+ params['cookies']['frontend.auid'] = ''.join(random.choice(
+ digg_cookie_chars) for _ in range(22))
return params