Anyhow, this script quite ineffeciently gets the kilocalorific (kcal) value of (some) foods:
#!/bin/bashOf course, you can see immediately that this is limited to the html formatting on the page above - which in turn means you have to enter your query auf deutsch. Furthermore, you could probably reduce the number of times that sed is called significantly. And you could grep more than just one foodstuff quite easily either. But this at least helped to get me up to speed for the 102.
searchterm=$1
data=$(curl -# 'http://www.med-surfer.de/kalorientabelle/kalorientabelle.php3')
echo $data | egrep -i "
.*
" | sed -e "s/<\/td>/<\/td>\n/g" | egrep -i "value='.*kcal.*'>" | sed -e "s/.*value='//g" | sed -e "s/'><\/td>$//g" | sed -e "s/\.\+/ /g" | sed -e "s/kcal/kcal pro 100g hat/g" | iconv -f iso-8859-1 | grep -i $searchterm
By the way, everything after the echo $data above is on one single line - the blog format might split it up. Otherwise, do:
- wget http://www.foxhall.de/downloads/kal.sh
- chmod +x kal.sh
- ./kal.sh apfel
Keine Kommentare:
Kommentar veröffentlichen