SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] update digg engine
Adam Tauber1057e42cfdc1
diff --git a/searx/engines/digg.py b/searx/engines/digg.pyindex 4369ccb84..073410eb0 100644--- a/searx/engines/digg.py+++ b/searx/engines/digg.py@@ -15,7 +15,8 @@ import stringfrom dateutil import parserfrom json import loadsfrom lxml import html-from searx.url_utils import quote_plus+from searx.url_utils import urlencode+from datetime import datetime# engine dependent configcategories = ['news', 'social media']@@ -23,7 +24,7 @@ paging = True# search-urlbase_url = 'https://digg.com/'-search_url = base_url + 'api/search/{query}.json?position={position}&format=html'+search_url = base_url + 'api/search/?{query}&from={position}&size=20&format=html'# specific xpath variablesresults_xpath = '//article'@@ -38,9 +39,9 @@ digg_cookie_chars = string.ascii_uppercase + string.ascii_lowercase +\# do search-requestdef request(query, params):- offset = (params['pageno'] - 1) * 10+ offset = (params['pageno'] - 1) * 20params['url'] = search_url.format(position=offset,- query=quote_plus(query))+ query=urlencode({'q': query}))params['cookies']['frontend.auid'] = ''.join(random.choice(digg_cookie_chars) for _ in range(22))return params@@ -52,30 +53,17 @@ def response(resp):search_result = loads(resp.text)- if 'html' not in search_result or search_result['html'] == '':- return results-- dom = html.fromstring(search_result['html'])-# parse results- for result in dom.xpath(results_xpath):- url = result.attrib.get('data-contenturl')- thumbnail = result.xpath('.//img')[0].attrib.get('src')- title = ''.join(result.xpath(title_xpath))- content = ''.join(result.xpath(content_xpath))- pubdate = result.xpath(pubdate_xpath)[0].attrib.get('datetime')- publishedDate = parser.parse(pubdate)-- # http to https- thumbnail = thumbnail.replace("http://static.digg.com", "https://static.digg.com")+ for result in search_result['mapped']:+ published = datetime.strptime(result['created']['ISO'], "%Y-%m-%d %H:%M:%S")# append result- results.append({'url': url,- 'title': title,- 'content': content,+ results.append({'url': result['url'],+ 'title': result['title'],+ 'content': result['excerpt'],'template': 'videos.html',- 'publishedDate': publishedDate,- 'thumbnail': thumbnail})+ 'publishedDate': published,+ 'thumbnail': result['images']['thumbImage']})# return resultsreturn results