mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 02:22:22 +02:00
Google news' unit test
This commit is contained in:
parent
d5b8005ee1
commit
b7dc1fb9d5
3 changed files with 141 additions and 2 deletions
|
@ -20,7 +20,7 @@ language_support = True
|
|||
|
||||
# engine dependent config
|
||||
url = 'https://ajax.googleapis.com/'
|
||||
search_url = url + 'ajax/services/search/news?v=2.0&start={offset}&rsz=large&safe=off&filter=off&{query}&hl={language}' # noqa
|
||||
search_url = url + 'ajax/services/search/news?v=2.0&start={offset}&rsz=large&safe=off&filter=off&{query}&hl={lang}'
|
||||
|
||||
|
||||
# do search-request
|
||||
|
@ -33,7 +33,7 @@ def request(query, params):
|
|||
|
||||
params['url'] = search_url.format(offset=offset,
|
||||
query=urlencode({'q': query}),
|
||||
language=language)
|
||||
lang=language)
|
||||
|
||||
return params
|
||||
|
||||
|
@ -52,6 +52,8 @@ def response(resp):
|
|||
for result in search_res['responseData']['results']:
|
||||
# parse publishedDate
|
||||
publishedDate = parser.parse(result['publishedDate'])
|
||||
if 'url' not in result:
|
||||
continue
|
||||
|
||||
# append result
|
||||
results.append({'url': result['unescapedUrl'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue