mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
fix(google_cs): Remove rate limit handling error, as it already use 429 code
This commit is contained in:
parent
8289232f2c
commit
ba1464fde4
1 changed files with 0 additions and 13 deletions
|
@ -40,8 +40,6 @@ from urllib.parse import urlencode
|
||||||
from dateutil.parser import isoparse
|
from dateutil.parser import isoparse
|
||||||
|
|
||||||
from searx.engines.google import get_lang_info
|
from searx.engines.google import get_lang_info
|
||||||
from searx.exceptions import SearxEngineTooManyRequestsException
|
|
||||||
from searx.network import raise_for_httperror
|
|
||||||
|
|
||||||
about = {
|
about = {
|
||||||
"website": 'https://www.google.com',
|
"website": 'https://www.google.com',
|
||||||
|
@ -190,22 +188,11 @@ def request(query, params):
|
||||||
|
|
||||||
params['url'] = base_url.format(query=urlencode(query))
|
params['url'] = base_url.format(query=urlencode(query))
|
||||||
params['headers']['X-Goog-Api-Key'] = api_key
|
params['headers']['X-Goog-Api-Key'] = api_key
|
||||||
params['raise_for_httperror'] = False
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
def response(resp):
|
def response(resp):
|
||||||
result = resp.json()
|
result = resp.json()
|
||||||
|
|
||||||
if resp.status_code == 403:
|
|
||||||
try:
|
|
||||||
if result['errors'][0]['reason'] == 'quotaExceeded':
|
|
||||||
raise SearxEngineTooManyRequestsException(message=result['message'])
|
|
||||||
except (KeyError, IndexError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
raise_for_httperror(resp)
|
|
||||||
|
|
||||||
metadata = [
|
metadata = [
|
||||||
{'number_of_results': min(MAX_SEARCH_RESULT, int(result['searchInformation']['totalResults'], 10))},
|
{'number_of_results': min(MAX_SEARCH_RESULT, int(result['searchInformation']['totalResults'], 10))},
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Reference in a new issue