Chequeo user agents en _do_request

This commit is contained in:
Daniel Cortes
2020-06-08 01:48:02 -04:00
parent 67e5e8a7a2
commit 6498bf9c48

View File

@@ -28,6 +28,8 @@ def _do_request(url):
""" """
if not url: if not url:
raise ValueError('URL cant be empty') raise ValueError('URL cant be empty')
if not HEADERS['user-agent']:
raise ValueError('User Agent isn\'t set')
_log.info('Doing request to "%s" with headers %s', url, HEADERS) _log.info('Doing request to "%s" with headers %s', url, HEADERS)
response = requests.get(url, headers=HEADERS) response = requests.get(url, headers=HEADERS)
@@ -52,9 +54,6 @@ def _do_request_mb(url):
:return: The dictionary with the response or the status and his an error message :return: The dictionary with the response or the status and his an error message
""" """
if not HEADERS['user-agent']:
raise ValueError('User Agent isn\'t set')
response = _do_request(url) response = _do_request(url)
if response.status_code == 200: if response.status_code == 200:
@@ -79,8 +78,6 @@ def _do_request_ca(url):
:raises ValueError when user-agent isn't set :raises ValueError when user-agent isn't set
:return: The dictionary with the response or the status and his an error message :return: The dictionary with the response or the status and his an error message
""" """
if not HEADERS['user-agent']:
raise ValueError('User Agent isn\'t set')
response = _do_request(url) response = _do_request(url)