Path: ...!news.mixmin.net!aioe.org!8V/RyHTQh/qvHt+9oBZ6lA.user.46.165.242.75.POSTED!not-for-mail From: Alain Ketterlin Newsgroups: fr.comp.lang.python Subject: Re: Tentative de transcription d'une ligne de commande =?utf-8?Q?=C2=AB?= Curl =?utf-8?B?wrsgw6A=?= l'aide de =?utf-8?Q?=C2=AB?= urllib3 =?utf-8?Q?=C2=BB=2E?= Date: Thu, 20 Jan 2022 18:25:19 +0100 Organization: =?utf-8?Q?Universit=C3=A9?= de Strasbourg Message-ID: <87h79ypbeo.fsf@universite-de-strasbourg.fr.invalid> References: <87lezbntpp.fsf@s02.forall> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: gioia.aioe.org; logging-data="16624"; posting-host="8V/RyHTQh/qvHt+9oBZ6lA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) X-Notice: Filtered by postfilter v. 0.9.2 Cancel-Lock: sha1:Cl5j2XzZZ4ZuSh6up4K6xqu5kxE= Bytes: 3991 Lines: 75 Valrik writes: > je suis grand d=C3=A9butant en Python, Json et Graphql. Mes questions, do= nc, > pourront peut-=C3=AAtre vous para=C3=AEtre na=C3=AFves. Je n'ai aucune id=C3=A9e de ce qu'est graphql. > curl 'https://openapi.radiofrance.fr/v1/graphql?x-token=3Dcl=C3=A9_que_je= _ne_peux_pas_rendre_publique_pour_l'instant' -H 'Accept-Encoding: gzip, def= late, br' -H 'Content-Type: application/json' -H 'Accept: application/json'= -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://openapi.radiof= rance.fr' --data-binary '{"query":"{\n diffusionsOfShowByUrl(url: \"https:= //www.franceculture.fr/emissions/fictions-theatre-et-cie\", first: 10) {\n\= t edges {\n cursor\n node {\n id\n title\n = url\n published_date\n podcastEpisode {\n = url\n title\n }\n }\n }\n }\n}"}' --compressed > > =C3=80 noter que cela fonctionne correctement dans un terminal. OK. > import urllib3 > > data_binary=3D'{"query":"{\n diffusionsOfShowByUrl(url: \"https://www.fr= anceculture.fr/emissions/fictions-theatre-et-cie\", first: 10) {\n\t edges = {\n cursor\n node {\n id\n title\n url= \n published_date\n podcastEpisode {\n url\n = title\n }\n }\n }\n }\n}"}' Tu ne fais jamais rien de ces donn=C3=A9es, alors qu'il me semble qu'elles doivent partir vers le serveur (en tout cas, c'est ce que fait curl). > http =3D urllib3.PoolManager() > > r =3D http.request( > 'GET', S'il y a des donn=C3=A9es =C3=A0 transmettre, il faut bien qu'elles soient = quelque part. Avec GET, ce serait dans l'uri. Mais si j'en crois ta commande curl, c'est en POST qu'elles sont envoy=C3=A9es (=C3=A0 cause de --data-binary), et c'est du JSON. Jette un o= eil =C3=A0 https://urllib3.readthedocs.io/en/stable/user-guide.html#json > 'https://openapi.radiofrance.fr/v1/graphql?x-token=3Dcl=C3=A9_que_je_= ne_peux_pas_rendre_publique_pour_l'instant', > headers=3D{ > 'Accept-Encoding': 'gzip, deflate, br', > 'Content-Type': 'application/json', > 'Accept': 'application/json', > 'Connection': 'keep-alive', > 'DNT': '1', # Obsol=C3=A8te. > 'Origin': 'https://openapi.radiofrance.fr' > } > ) > Je n'est =C3=A9galement rien trouv=C3=A9 sur =C2=AB --compressed =C2=BB, = mais je dois avouer > que j'ai fait beaucoup moins de recherche. Moi je fais "man curl" et je trouve : | --compressed | (HTTP) Request a compressed response using one of the algorithms | curl supports, and save the uncompressed document. If this | option is used and the server sends an unsupported encoding, | curl will report an error. |=20 Mes 2 cents. -- Alain.