mirror of
https://github.com/searxng/searxng.git
synced 2024-11-29 22:21:02 +00:00
Add searx user agent to Reddit engine request to comply with API usage terms
This commit is contained in:
parent
0bfbdff234
commit
d0001f10e6
2 changed files with 6 additions and 0 deletions
|
@ -15,6 +15,7 @@ from cgi import escape
|
|||
from urllib import urlencode
|
||||
from urlparse import urlparse
|
||||
from datetime import datetime
|
||||
from searx.utils import searx_useragent
|
||||
|
||||
# engine dependent config
|
||||
categories = ['general', 'images', 'news', 'social media']
|
||||
|
@ -30,6 +31,9 @@ def request(query, params):
|
|||
'limit': page_size})
|
||||
params['url'] = search_url.format(query=query)
|
||||
|
||||
# using searx User-Agent
|
||||
params['headers']['User-Agent'] = searx_useragent()
|
||||
|
||||
return params
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import mock
|
|||
from searx.engines import reddit
|
||||
from searx.testing import SearxTestCase
|
||||
from datetime import datetime
|
||||
from searx.utils import searx_useragent
|
||||
|
||||
|
||||
class TestRedditEngine(SearxTestCase):
|
||||
|
@ -14,6 +15,7 @@ class TestRedditEngine(SearxTestCase):
|
|||
self.assertTrue('url' in params)
|
||||
self.assertTrue(query in params['url'])
|
||||
self.assertTrue('reddit.com' in params['url'])
|
||||
self.assertEqual(params['headers']['User-Agent'], searx_useragent())
|
||||
|
||||
def test_response(self):
|
||||
resp = mock.Mock(text='{}')
|
||||
|
|
Loading…
Reference in a new issue