0

I make a get request to the site, I get an error in response. Why is this happening??

import requests
import fake_useragent

user = fake_useragent.UserAgent().random
header = {'user-agent': user}

html_URL = requests.get("https://barefootleather.co.uk/", headers=header, timeout=10)

print(html_URL.status_code)

My error

Traceback (most recent call last):
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.9/ssl.py", line 501, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.9/ssl.py", line 1041, in _create
    self.do_handshake()
  File "/usr/lib/python3.9/ssl.py", line 1310, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='barefootleather.co.uk', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kali/Desktop/python/CMS_type_shop/test.py", line 7, in <module>
    html_URL = requests.get("https://barefootleather.co.uk/", headers=header, timeout=10)
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/kali/Desktop/python/CMS_type_shop/venv/lib/python3.9/site-packages/requests/adapters.py", line 563, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='barefootleather.co.uk', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
scotscotmcc
  • 2,719
  • 1
  • 6
  • 29
Valera
  • 1
  • did you try `get(..., verify=False)` ? – furas Oct 26 '22 at 16:45
  • did you check this page in web browser? You should also check cerification in web browser - maybe portla has outdated certification. – furas Oct 26 '22 at 16:47
  • did you search `SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate` in Google? I found [python - certificate verify failed: unable to get local issuer certificate - Stack Overflow](https://stackoverflow.com/questions/52805115/certificate-verify-failed-unable-to-get-local-issuer-certificate) – furas Oct 26 '22 at 16:50
  • this also looks interesting [python - CERTIFICATE\_VERIFY\_FAILED error - Ask Ubuntu](https://askubuntu.com/questions/1401379/certificate-verify-failed-error) – furas Oct 26 '22 at 16:54
  • Usually this means your Python installation doesn't have access to a CA cert store. Where are you running this, and how did you install Python? – Max Oct 26 '22 at 17:24
  • python was preinstalled in kali linux – Valera Oct 27 '22 at 04:36

0 Answers0