All links of one day
in a single page.
<Previous day - Next day>

rss_feedDaily RSS Feed
floral_left The Daily Shaarli floral_right
——————————— March 8, 2022 - Tuesday 08, March 2022 ———————————
script -

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>" > $outfile
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 &euro; 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

-