mirror of
https://github.com/searxng/searxng.git
synced 2024-11-20 03:10:10 +01:00
[fix] kickass engine : change the hostname to kickass.to (since kickass.so doesn't respond).
Close #197 perhaps not in clean way. Explanation :
In fact 301 responses are followed, except the hook is called for each HTTP response,
the first time for the HTTP 301 response then for HTTP 200 response.
Since the kickass engine excepts a real result, the engine crashes, AND the requests lib stops here.
Add a simple test at the beginning of the result function allows pass the first response and handle correctly the second response (the real one)
May be a proper way is to add this test in search.py ?
Code inside requests :
53d02381e2/requests/sessions.py (L579)
and line 591
This commit is contained in:
parent
f8a5f7d675
commit
9db0bbc304
@ -20,7 +20,7 @@ categories = ['videos', 'music', 'files']
|
|||||||
paging = True
|
paging = True
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
url = 'https://kickass.so/'
|
url = 'https://kickass.to/'
|
||||||
search_url = url + 'search/{search_term}/{pageno}/'
|
search_url = url + 'search/{search_term}/{pageno}/'
|
||||||
|
|
||||||
# specific xpath variables
|
# specific xpath variables
|
||||||
@ -45,6 +45,11 @@ def request(query, params):
|
|||||||
def response(resp):
|
def response(resp):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
|
# check if redirect comparing to the True value,
|
||||||
|
# because resp can be a Mock object, and any attribut name returns something.
|
||||||
|
if resp.is_redirect == True:
|
||||||
|
return results
|
||||||
|
|
||||||
dom = html.fromstring(resp.text)
|
dom = html.fromstring(resp.text)
|
||||||
|
|
||||||
search_res = dom.xpath('//table[@class="data"]//tr')
|
search_res = dom.xpath('//table[@class="data"]//tr')
|
||||||
|
@ -14,7 +14,7 @@ class TestKickassEngine(SearxTestCase):
|
|||||||
params = kickass.request(query, dicto)
|
params = kickass.request(query, dicto)
|
||||||
self.assertIn('url', params)
|
self.assertIn('url', params)
|
||||||
self.assertIn(query, params['url'])
|
self.assertIn(query, params['url'])
|
||||||
self.assertIn('kickass.so', params['url'])
|
self.assertIn('kickass.to', params['url'])
|
||||||
self.assertIn('verify', params)
|
self.assertIn('verify', params)
|
||||||
self.assertFalse(params['verify'])
|
self.assertFalse(params['verify'])
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class TestKickassEngine(SearxTestCase):
|
|||||||
self.assertEqual(type(results), list)
|
self.assertEqual(type(results), list)
|
||||||
self.assertEqual(len(results), 1)
|
self.assertEqual(len(results), 1)
|
||||||
self.assertEqual(results[0]['title'], 'This should be the title')
|
self.assertEqual(results[0]['title'], 'This should be the title')
|
||||||
self.assertEqual(results[0]['url'], 'https://kickass.so/url.html')
|
self.assertEqual(results[0]['url'], 'https://kickass.to/url.html')
|
||||||
self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted')
|
self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted')
|
||||||
self.assertEqual(results[0]['seed'], 10)
|
self.assertEqual(results[0]['seed'], 10)
|
||||||
self.assertEqual(results[0]['leech'], 1)
|
self.assertEqual(results[0]['leech'], 1)
|
||||||
@ -381,7 +381,7 @@ class TestKickassEngine(SearxTestCase):
|
|||||||
self.assertEqual(type(results), list)
|
self.assertEqual(type(results), list)
|
||||||
self.assertEqual(len(results), 5)
|
self.assertEqual(len(results), 5)
|
||||||
self.assertEqual(results[0]['title'], 'This should be the title')
|
self.assertEqual(results[0]['title'], 'This should be the title')
|
||||||
self.assertEqual(results[0]['url'], 'https://kickass.so/url.html')
|
self.assertEqual(results[0]['url'], 'https://kickass.to/url.html')
|
||||||
self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted')
|
self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted')
|
||||||
self.assertEqual(results[0]['seed'], 10)
|
self.assertEqual(results[0]['seed'], 10)
|
||||||
self.assertEqual(results[0]['leech'], 1)
|
self.assertEqual(results[0]['leech'], 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user