diff --git a/searx/engines/gigablast.py b/searx/engines/gigablast.py
index a84f3f69d..2bb29a9fe 100644
--- a/searx/engines/gigablast.py
+++ b/searx/engines/gigablast.py
@@ -14,6 +14,7 @@ import random
from json import loads
from time import time
from lxml.html import fromstring
+from searx.poolrequests import get
from searx.url_utils import urlencode
from searx.utils import eval_xpath
@@ -31,13 +32,9 @@ search_string = 'search?{query}'\
'&c=main'\
'&s={offset}'\
'&format=json'\
- '&qh=0'\
- '&qlang={lang}'\
+ '&langcountry={lang}'\
'&ff={safesearch}'\
- '&rxiec={rxieu}'\
- '&ulse={ulse}'\
- '&rand={rxikd}'\
- '&dbez={dbez}'
+ '&rand={rxikd}'
# specific xpath variables
results_xpath = '//response//result'
url_xpath = './/url'
@@ -46,9 +43,26 @@ content_xpath = './/sum'
supported_languages_url = 'https://gigablast.com/search?&rxikd=1'
+extra_param = '' # gigablast requires a random extra parameter
+# which can be extracted from the source code of the search page
+
+
+def parse_extra_param(text):
+ global extra_param
+ param_lines = [x for x in text.splitlines() if x.startswith('var url=') or x.startswith('url=url+')]
+ extra_param = ''
+ for l in param_lines:
+ extra_param += l.split("'")[1]
+ extra_param = extra_param.split('&')[-1]
+
+
+def init(engine_settings=None):
+ parse_extra_param(get('http://gigablast.com/search?c=main&qlangcountry=en-us&q=south&s=10').text)
+
# do search-request
def request(query, params):
+ print("EXTRAPARAM:", extra_param)
offset = (params['pageno'] - 1) * number_of_results
if params['language'] == 'all':
@@ -67,14 +81,11 @@ def request(query, params):
search_path = search_string.format(query=urlencode({'q': query}),
offset=offset,
number_of_results=number_of_results,
- rxikd=int(time() * 1000),
- rxieu=random.randint(1000000000, 9999999999),
- ulse=random.randint(100000000, 999999999),
lang=language,
- safesearch=safesearch,
- dbez=random.randint(100000000, 999999999))
+ rxikd=int(time() * 1000),
+ safesearch=safesearch)
- params['url'] = base_url + search_path
+ params['url'] = base_url + search_path + '&' + extra_param
return params
@@ -84,7 +95,11 @@ def response(resp):
results = []
# parse results
- response_json = loads(resp.text)
+ try:
+ response_json = loads(resp.text)
+ except:
+ parse_extra_param(resp.text)
+ raise Exception('extra param expired, please reload')
for result in response_json['results']:
# append result
diff --git a/searx/engines/openstreetmap.py b/searx/engines/openstreetmap.py
index 733ba6203..cec10a3c7 100644
--- a/searx/engines/openstreetmap.py
+++ b/searx/engines/openstreetmap.py
@@ -24,7 +24,7 @@ result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}'
# do search-request
def request(query, params):
- params['url'] = base_url + search_string.format(query=query)
+ params['url'] = base_url + search_string.format(query=query.decode('utf-8'))
return params
diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py
index de12955c6..54e9dafad 100644
--- a/searx/engines/qwant.py
+++ b/searx/engines/qwant.py
@@ -50,6 +50,7 @@ def request(query, params):
language = match_language(params['language'], supported_languages, language_aliases)
params['url'] += '&locale=' + language.replace('-', '_').lower()
+ params['headers']['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0'
return params
diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py
index 4dae735d1..a216ba886 100644
--- a/searx/engines/wikipedia.py
+++ b/searx/engines/wikipedia.py
@@ -21,7 +21,8 @@ search_url = base_url + u'w/api.php?'\
'action=query'\
'&format=json'\
'&{query}'\
- '&prop=extracts|pageimages'\
+ '&prop=extracts|pageimages|pageprops'\
+ '&ppprop=disambiguation'\
'&exintro'\
'&explaintext'\
'&pithumbsize=300'\
@@ -79,12 +80,15 @@ def response(resp):
# wikipedia article's unique id
# first valid id is assumed to be the requested article
+ if 'pages' not in search_result['query']:
+ return results
+
for article_id in search_result['query']['pages']:
page = search_result['query']['pages'][article_id]
if int(article_id) > 0:
break
- if int(article_id) < 0:
+ if int(article_id) < 0 or 'disambiguation' in page.get('pageprops', {}):
return []
title = page.get('title')
@@ -96,6 +100,7 @@ def response(resp):
extract = page.get('extract')
summary = extract_first_paragraph(extract, title, image)
+ summary = summary.replace('() ', '')
# link to wikipedia article
wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \
diff --git a/searx/webapp.py b/searx/webapp.py
index 7cf4106d3..212c874c9 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -606,11 +606,11 @@ def index():
# HTML output format
# suggestions: use RawTextQuery to get the suggestion URLs with the same bang
- suggestion_urls = map(lambda suggestion: {
- 'url': raw_text_query.changeSearchQuery(suggestion).getFullQuery(),
- 'title': suggestion
- },
- result_container.suggestions)
+ suggestion_urls = list(map(lambda suggestion: {
+ 'url': raw_text_query.changeSearchQuery(suggestion).getFullQuery(),
+ 'title': suggestion
+ },
+ result_container.suggestions))
correction_urls = list(map(lambda correction: {
'url': raw_text_query.changeSearchQuery(correction).getFullQuery(),
diff --git a/tests/unit/engines/__init__.py b/tests/unit/engines/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/unit/engines/pubmed.py b/tests/unit/engines/pubmed.py
deleted file mode 100644
index 370efe067..000000000
--- a/tests/unit/engines/pubmed.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- coding: utf-8 -*-
-from collections import defaultdict
-import mock
-from searx.engines import pubmed
-from searx.testing import SearxTestCase
-
-
-class TestPubmedEngine(SearxTestCase):
-
- def test_request(self):
- query = 'test_query'
- dicto = defaultdict(dict)
- dicto['pageno'] = 1
- params = pubmed.request(query, dicto)
- self.assertIn('url', params)
- self.assertIn('eutils.ncbi.nlm.nih.gov/', params['url'])
- self.assertIn('term', params['url'])
-
- def test_response(self):
- self.assertRaises(AttributeError, pubmed.response, None)
- self.assertRaises(AttributeError, pubmed.response, [])
- self.assertRaises(AttributeError, pubmed.response, '')
- self.assertRaises(AttributeError, pubmed.response, '[]')
-
- response = mock.Mock(text='
- - | - - - Torrent name | Age | Size | Seeds | Peers | Health | |
---|---|---|---|---|---|---|
Narcos season 2 Full Version | 20 hours | 681.3 MB | 28 | 654 | ||
Narcos season 2 Trusted Source | 12 hours | 787.1 MB | 64 | 220 | ||
Full Narcos season 2 Download Usenet | 24 hours | 775.5 MB | 60 | 236 | ||
Narcos season 2 2014 - DIRECT STREAMING Movies | 17 hours | 654.1 MB | 2 | 391 | ||
Narcos season 2 2014 Movies | 20 hours | 754.5 MB | 21 | 919 |
- - | - - - Torrent name | Age | Size | Seeds | Peers | Health |
---|---|---|---|---|---|
Narcos Season 2 Complete 720p WebRip EN-SUB x264-[MULVAcoded] S02 | 19 hours | 4.39 GB | 715 | 183 | |
Narcos - Season 2 - 720p WEBRiP - x265 HEVC - ShAaNiG | 1 day | 2.48 GB | 861 | 332 |
test | -test | -test | -test | -test | -test | -test | -test | -
---|---|---|---|---|---|---|---|
date | -testcategory テスト | -- torrentname テスト - | -1MB | -- - 29 - - | -- - 211 - - | -- - 168 - - | -user | -
This should be the content.
-This should be the content.
-This should be the content.
-
-
-
- The Big Bang Theory
-
- 4 hours ago
-
-
-
-
- Files: 1 Size: 2.9 GB Downloads: 1 Updated: 4 hours ago
-
-
- magnet-link
-
-
-
- |
This is the content
-VERSION INTEGRALE DE LA CONFERENCE DE PRESSE DU GENERAL DE GAULLE . \ - - PA le Pr\\u00e9sident DE GAULLE : il ouvre les bras et s'assied. DP journalis...<\\/p>\\n\ - <\\/div>\\n<\\/div>\\n" - } - """ - response = mock.Mock(text=json) - results = ina.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 1) - self.assertEqual(results[0]['title'], u'Conf\xe9rence de presse du G\xe9n\xe9ral de Gaulle') - self.assertEqual(results[0]['url'], - 'https://www.ina.fr/video/CAF89035682/conference-de-presse-du-general-de-gaulle-video.html') - self.assertEqual(results[0]['content'], - u"VERSION INTEGRALE DE LA CONFERENCE DE PRESSE DU GENERAL DE GAULLE ." - u" - PA le Pr\u00e9sident DE GAULLE : il ouvre les bras et s'assied. DP journalis...") diff --git a/tests/unit/engines/test_kickass.py b/tests/unit/engines/test_kickass.py deleted file mode 100644 index 3a75c6697..000000000 --- a/tests/unit/engines/test_kickass.py +++ /dev/null @@ -1,397 +0,0 @@ -# -*- coding: utf-8 -*- -from collections import defaultdict -import mock -from searx.engines import kickass -from searx.testing import SearxTestCase - - -class TestKickassEngine(SearxTestCase): - - def test_request(self): - query = 'test_query' - dicto = defaultdict(dict) - dicto['pageno'] = 1 - params = kickass.request(query, dicto) - self.assertIn('url', params) - self.assertIn(query, params['url']) - self.assertIn('kickass.cd', params['url']) - self.assertFalse(params['verify']) - - def test_response(self): - self.assertRaises(AttributeError, kickass.response, None) - self.assertRaises(AttributeError, kickass.response, []) - self.assertRaises(AttributeError, kickass.response, '') - self.assertRaises(AttributeError, kickass.response, '[]') - - response = mock.Mock(text='') - self.assertEqual(kickass.response(response), []) - - html = """ -
torrent name | -- size - | -- files - | -- age - | -- seed - | -- leech - | -
---|---|---|---|---|---|
- - | -449 bytes | -4 | -2 years | -10 | -1 | -
torrent name | -- size - | -- files - | -- age - | -- seed - | -- leech - | -
---|
torrent name | -- size - | -- files - | -- age - | -- seed - | -- leech - | -
---|---|---|---|---|---|
- - | -1 KiB | -4 | -2 years | -10 | -1 | -
- - | -1 MiB | -4 | -2 years | -9 | -1 | -
- - | -1 GiB | -4 | -2 years | -8 | -1 | -
- - | -1 TiB | -4 | -2 years | -7 | -1 | -
- - | -z bytes | -r | -2 years | -a | -t | -
- Category
- |
-
- Name
- |
- - - - | -
- Link
- |
-
-
- Size
- |
-
-
- Date
- |
- - - - | -- - - | -- - - | -
---|---|---|---|---|---|---|---|---|
- - - - | -- Sample title 1 - | -- - - | -723.7 MiB | -2017-08-21 11:24 | -1 | -3 | -12 | -|
- - - - | -- Sample title 2 - | -- - | -8.2 GiB | -2017-04-08 01:40 | -10 | -1 | -206 | -
- - (Anime) - |
- - - - - - - - - - - - - - This is the content and should be OK - - | -13 | -334 | -
- - (Anime) - |
- - - - - - - - - - - This is the content and should be OK - - | -13 | -334 | -
- - (Anime) - |
- - - - - - - - - - - - - - This is the content and should be OK - - | -s | -d | -
Title | -1 year | -1 KB | -10 | -20 | -- |
- - | -- - - - - Koyomimonogatari - - | -Details | -
- Authorized: Yes - Submitter: Ohys | - Size: 10.5MB | - Date: 2016-03-26 16:41 UTC | - Comment: sample comment - | -- S: 53 - L: 18 - C: 0 - ID: 975700 - | -|
- - | -- - Owarimonogatari - - | -Details | -
- Submitter: Ohys | - Size: 932.84EB | - Date: QWERTY-03-26 16:41 UTC - | -- S: 0 - | -
- This is the content étude à€ - - - - http://link.in.tweet - - - - - - - pic.twitter.com/rbFsfeE0l3 - -
- - -- This is the content étude à€ - - - - http://link.in.tweet - - - - - - - pic.twitter.com/rbFsfeE0l3 - -
- - -- This should be the content.
-N | -Language | -Language (local) | -Wiki | -Articles | -
---|---|---|---|---|
2 | -Swedish | -Svenska | -sv | -3000000 | -
3 | -Cebuano | -Sinugboanong Binisaya | -ceb | -3000000 | -
N | -Language | -Language (local) | -Wiki | -Articles | -
---|---|---|---|---|
2 | -Norwegian (Bokmål) | -Norsk (Bokmål) | -no | -100000 | -
This is the content -
-This is the second content
-This is the suggestion - | -
This is the content -
-