Bonjour

j'obtiens une série de messages d'erreur lorsque j'écris ces lignes de code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
import requests
import json
 
url="https://api.nytimes.com/svc/archive/v1/2019/1.json"
reponse=requests.get(url)
print(reponse.status_code)
 
def jprint(obj):
    # crée une chaîne formatée de l'objet Python JSON
    texte = json.dumps(obj, sort_keys = True, indent = 4)
    print (texte)
 
jprint(reponse.json())
Et voici les messages que je reçois:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
runfile('D:/Données/Informatique/PYTHON/Dataquest_travaux/Api_NewYorkTimes.py', wdir='D:/Données/Informatique/PYTHON/Dataquest_travaux')
Reloaded modules: cryptography, cryptography.__about__, cryptography.hazmat, cryptography.hazmat.backends, cryptography.hazmat.backends.openssl, cryptography.hazmat.backends.openssl.backend, asn1crypto, asn1crypto.version, asn1crypto.core, asn1crypto._teletex_codec, asn1crypto._errors, asn1crypto._ordereddict, asn1crypto._types, asn1crypto.parser, asn1crypto.util, asn1crypto._iri, asn1crypto._inet, cryptography.utils, cryptography.x509, cryptography.x509.certificate_transparency, cryptography.x509.base, cryptography.hazmat.primitives, cryptography.hazmat.primitives.asymmetric, cryptography.hazmat.primitives.asymmetric.dsa, cryptography.hazmat.primitives.asymmetric.ec, cryptography.hazmat._oid, cryptography.hazmat.primitives.asymmetric.rsa, cryptography.exceptions, cryptography.hazmat.backends.interfaces, cryptography.x509.extensions, asn1crypto.keys, asn1crypto._elliptic_curve, asn1crypto._int, asn1crypto._ffi, asn1crypto._perf, asn1crypto.algos, cryptography.hazmat.primitives.constant_time, cryptography.hazmat.bindings, cryptography.hazmat.bindings._constant_time, cryptography.hazmat.primitives.serialization, cryptography.x509.general_name, idna, idna.package_data, idna.core, idna.idnadata, idna.intranges, cryptography.x509.name, cryptography.x509.oid, cryptography.hazmat.primitives.hashes, cryptography.hazmat.backends.openssl.aead, cryptography.hazmat.backends.openssl.ciphers, cryptography.hazmat.primitives.ciphers, cryptography.hazmat.primitives.ciphers.base, cryptography.hazmat.primitives.ciphers.modes, cryptography.hazmat.backends.openssl.cmac, cryptography.hazmat.primitives.mac, cryptography.hazmat.backends.openssl.decode_asn1, cryptography.hazmat.backends.openssl.dh, cryptography.hazmat.primitives.asymmetric.dh, cryptography.hazmat.backends.openssl.dsa, cryptography.hazmat.backends.openssl.utils, cryptography.hazmat.primitives.asymmetric.utils, cryptography.hazmat.backends.openssl.ec, cryptography.hazmat.backends.openssl.encode_asn1, cryptography.hazmat.backends.openssl.hashes, cryptography.hazmat.backends.openssl.hmac, cryptography.hazmat.backends.openssl.ocsp, cryptography.hazmat.backends.openssl.x509, cryptography.x509.ocsp, cryptography.hazmat.backends.openssl.rsa, cryptography.hazmat.primitives.asymmetric.padding, cryptography.hazmat.backends.openssl.x25519, cryptography.hazmat.primitives.asymmetric.x25519, cryptography.hazmat.bindings.openssl, cryptography.hazmat.bindings.openssl.binding, cryptography.hazmat.bindings._openssl, cryptography.hazmat.bindings.openssl._conditional, cryptography.hazmat.primitives.ciphers.algorithms, cryptography.hazmat.primitives.kdf, cryptography.hazmat.primitives.kdf.scrypt
Traceback (most recent call last):
 
  File "<ipython-input-20-3a60016a961d>", line 1, in <module>
    runfile('D:/Données/Informatique/PYTHON/Dataquest_travaux/Api_NewYorkTimes.py', wdir='D:/Données/Informatique/PYTHON/Dataquest_travaux')
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
    execfile(filename, namespace)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
 
  File "D:/Données/Informatique/PYTHON/Dataquest_travaux/Api_NewYorkTimes.py", line 12, in <module>
    reponse=requests.get(url)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
    conn.connect()
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\urllib3\connection.py", line 355, in connect
    cert = self.sock.getpeercert()
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 360, in getpeercert
    'subjectAltName': get_subj_alt_name(x509)
 
  File "C:\Users\PCAlain\Anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 211, in get_subj_alt_name
    x509.SubjectAlternativeName
 
  File "C:\Users\PCAlain\AppData\Roaming\Python\Python37\site-packages\cryptography\x509\extensions.py", line 96, in get_extension_for_class
    "No {0} extension was found".format(extclass), extclass.oid
 
ExtensionNotFound: No <class 'cryptography.x509.extensions.SubjectAlternativeName'> extension was found
Quelqu'un peut-il m'aider ?
Merci d'avance.

AlainAstro