Deutsch   English   Français   Italiano  
<87lezbntpp.fsf@s02.forall>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!2.us.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!agneau.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-a.proxad.net!nnrp1-1.free.fr!not-for-mail
From: Valrik <nospam@valrik.invalid>
Newsgroups: fr.comp.lang.python
Subject: 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 01:20:34 +0100
Message-ID: <87lezbntpp.fsf@s02.forall>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:MUwKuDaKadDoS5mm0bCOQfX7Myw=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Lines: 73
Organization: Guest of ProXad - France
NNTP-Posting-Date: 20 Jan 2022 01:20:34 CET
NNTP-Posting-Host: 91.172.153.64
X-Trace: 1642638034 news-4.free.fr 8913 91.172.153.64:53926
X-Complaints-To: abuse@proxad.net
Bytes: 4082

Bonjour =C3=A0 tous,

je suis grand d=C3=A9butant en Python, Json et Graphql. Mes questions, donc,
pourront peut-=C3=AAtre vous para=C3=AEtre na=C3=AFves.

Je tente actuellement de programmer une petite application en lignes de
commandes (CLI) permettant de visualiser la grille des programmes de
Radio France. Openapi de Radio France, m'a fourni une cl=C3=A9 afin de
pouvoir me connecter sur leur serveur Graphql.

Il existe =C3=A9galement un =C2=AB terrain de jeux =C2=BB sur
https://openapi.radiofrance.fr/ avec des exemples. Il y a possibilit=C3=A9 =
de
copier la requ=C3=AAte et cela donne pour l'un des exemples :

curl 'https://openapi.radiofrance.fr/v1/graphql?x-token=3Dcl=C3=A9_que_je_n=
e_peux_pas_rendre_publique_pour_l'instant' -H 'Accept-Encoding: gzip, defla=
te, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -=
H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://openapi.radiofra=
nce.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            u=
rl\n            title\n          }\n      }\n    }\n  }\n}"}' --compressed

=C3=80 noter que cela fonctionne correctement dans un terminal.

J'ai tent=C3=A9 tant bien que mal de transcrire cette commande en Python et
voil=C3=A0 ce que cela donne :

import urllib3

data_binary=3D'{"query":"{\n  diffusionsOfShowByUrl(url: \"https://www.fran=
ceculture.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}"}'

http =3D urllib3.PoolManager()

r =3D http.request(
    'GET',
    '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'
    }
)

print(r.data)

Cela me retourne :
b'Must provide query string.'

Ce qui est plut=C3=B4t logique puisque il n'y a aucune requ=C3=AAte Graphql=
 !  ;-)

J'ai tent=C3=A9 de trouver la transcription correcte de celle-ci sur
Internet, =C3=A9pluch=C3=A9 la page Man de Curl, coder =C2=AB =C3=A0 l'arra=
che =C2=BB=E2=80=A6 rien n'y
fait !

Je n'est =C3=A9galement rien trouv=C3=A9 sur =C2=AB --compressed =C2=BB, ma=
is je dois avouer
que j'ai fait beaucoup moins de recherche.

Et bien voil=C3=A0, je pense avoir fait le tour de la question. Il ne me
reste plus qu'=C3=A0 vous remercier de votre attention.  :-)