3037 links
  • Nono's Links
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
page 1 / 1
  • Petit script pour lister le prix du carburant près de chez soit
    EDIT: 04/05/2022 J'ai ajouté le triage, merci à SebSauvage pour la modif ;-)

    Alors j'annonce, c'est moche, mais c'est juste ce qu'il me faut à moi, soit :
    - Basé sur l'opendata de prix-carburants.gouv.fr
    - Sans se créer de compte sur le site et gérer des favoris
    - Sans avoir la carte (qui ne m’intéresse pas)

    Et ça nécessite : xmllint, zcat, et potentiellement cron ...

    Pour les IDs des stations, j'ai téléchargé le .xml (archivé) et j'ai cherché les villes proche de chez moi, sinon en allant sur le site/la carte, il est possible de voir l'identifiant sur certains liens des détails
    --------------

    #!/bin/bash
    curl -s https://donnees.roulez-eco.fr/opendata/instantane | zcat > carburant.xml
    ids="00000001_description1 00000002_description2 00000003_description3"
    type_essence="Gazole" # Gazole, SP95, SP98, E85, E10
    out_file=/var/www/html/carburant.html
    prixTotal=""
    NL=$'\n'
    echo "<html><head></head> <meta charset="UTF-8"> <body>" > $out_file
    for id in $ids;
    do
            i=$(echo $id | cut -d'_' -f1)
            place=$(echo $id | cut -d'_' -f2)

            prix="$(xmllint --xpath 'string(/pdv_liste/pdv[@id='$i']/prix[@nom="'$type_essence'"]/@valeur)' carburant.xml)"
            adresse="$(xmllint --xpath 'string(/pdv_liste/pdv[@id='$i']/adresse)' carburant.xml)"
            ville="$(xmllint --xpath 'string(/pdv_liste/pdv[@id='$i']/ville)' carburant.xml)"
            maj="$(xmllint --xpath 'string(/pdv_liste/pdv[@id='$i']/prix[@nom="Gazole"]/@maj)' carburant.xml)"
            prixTotal+="$prix € a $place $ville ($maj)<br />${NL}"
    done
    prixTotal=$(echo "$prixTotal" | sort -n)
    echo ${prixTotal#?} >> $out_file
    echo "<br /><br/>MaJ: $(date)</body></html>" >> $out_file
    --------------
    March 8, 2022 at 9:33:55 PM GMT+1 * - permalink -
    QRCode
    - http://shaarli.m0le.net/?Fs5Qqg
    script
Links per page: 20 50 100
page 1 / 1
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation