Browse Source

Merge pull request #1015 from misnyo/digg

[fix] digg now requires cookie for search
Adam Tauber 7 years ago
parent
commit
610117d054
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      searx/engines/digg.py

+ 7
- 0
searx/engines/digg.py View File

10
  @parse       url, title, content, publishedDate, thumbnail
10
  @parse       url, title, content, publishedDate, thumbnail
11
 """
11
 """
12
 
12
 
13
+import random
14
+import string
13
 from dateutil import parser
15
 from dateutil import parser
14
 from json import loads
16
 from json import loads
15
 from lxml import html
17
 from lxml import html
30
 content_xpath = './/p//text()'
32
 content_xpath = './/p//text()'
31
 pubdate_xpath = './/time'
33
 pubdate_xpath = './/time'
32
 
34
 
35
+digg_cookie_chars = string.ascii_uppercase + string.ascii_lowercase +\
36
+    string.digits + "+_"
37
+
33
 
38
 
34
 # do search-request
39
 # do search-request
35
 def request(query, params):
40
 def request(query, params):
36
     offset = (params['pageno'] - 1) * 10
41
     offset = (params['pageno'] - 1) * 10
37
     params['url'] = search_url.format(position=offset,
42
     params['url'] = search_url.format(position=offset,
38
                                       query=quote_plus(query))
43
                                       query=quote_plus(query))
44
+    params['cookies']['frontend.auid'] = ''.join(random.choice(
45
+        digg_cookie_chars) for _ in range(22))
39
     return params
46
     return params
40
 
47
 
41
 
48