You need package libxml2 for xmllint.
#!/usr/bin/bash
url='http://www.tv5.org/TV5Site/widget/meteotv5_weather.php?ville_id=474'
xml=$(wget -q -O - "$url")
min=$(xmllint --xpath 'string(weather/forecast/item[1]/tempmin)' - <<< "$xml")
max=$(xmllint --xpath 'string(weather/forecast/item[1]/tempmax)' - <<< "$xml")
descr=$(xmllint --xpath 'string(weather/forecast/item[1]/descr)' - <<< "$xml")
echo "$min - $max: $descr"
Then in your TEXT section of your .conkyrc file put:
${exec script}
but replace 'script' with the filename of the above script.
]]><weather>
<data>
<ville>Paris</ville>
<pays>FRANCE</pays>
<date>Observation le vendredi 22 à 13:00 (heure locale)</date>
<temp>4°C</temp>
<descr>couvert </descr>
You don't want the value of this 'descr', but of the one a bit lower (the second one) -
<descr>très nuageux </descr>
thus '//descr[2]'.
]]>Could you explain what the command does exactly?
]]><item date="vendredi 22">
<libmin>Matin</libmin>
<tempmin>2°C</tempmin>
<libmax>Après-midi</libmax>
<tempmax>5°C</tempmax>
<descr>très nuageux </descr>
gets translated by
$ echo -e $(xml sel --net -t -m '//tempmin[1]' -v . -o "\n" -m '//tempmax[1]' -v . -o "\n" -m '//descr[2]' -v . -n http://www.tv5.org/TV5Site/widget/meteotv5_weather.php?ville_id=474)
into
2°C
5°C
très nuageux
Is this how you want it?
]]>I was trying to write a Conky script to display weather forecast for the current day in my Conky, using <tempmin>, <tempmax> and <descr> on this page http://www.tv5.org/TV5Site/widget/meteo … lle_id=474.
I'm a complete newbie to bash/perl/whatever, and I couldn't manage to do much. Could anyone explain me how to proceed?
Please don't RTFM me :(
]]>