From a49cc18f9c9b09c59daebe503f89d02d7357705f Mon Sep 17 00:00:00 2001 From: misnyo Date: Wed, 30 Aug 2017 18:20:43 +0200 Subject: [PATCH 1/2] [fix] digg now requires cookie for search --- searx/engines/digg.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/searx/engines/digg.py b/searx/engines/digg.py index 606747a4d..84f1ea599 100644 --- 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 @@ -36,6 +38,10 @@ 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( + string.ascii_uppercase + + string.ascii_lowercase + + string.digits + "+_") for _ in range(22)) return params From 6e92fb383ae8b39579fe7ddb5bc6b2ea6a4c93b4 Mon Sep 17 00:00:00 2001 From: misnyo Date: Wed, 30 Aug 2017 21:14:12 +0200 Subject: [PATCH 2/2] [fix] digg cookie characters created in module import --- searx/engines/digg.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/searx/engines/digg.py b/searx/engines/digg.py index 84f1ea599..4369ccb84 100644 --- a/searx/engines/digg.py +++ b/searx/engines/digg.py @@ -32,6 +32,9 @@ 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): @@ -39,9 +42,7 @@ def request(query, params): params['url'] = search_url.format(position=offset, query=quote_plus(query)) params['cookies']['frontend.auid'] = ''.join(random.choice( - string.ascii_uppercase + - string.ascii_lowercase + - string.digits + "+_") for _ in range(22)) + digg_cookie_chars) for _ in range(22)) return params