summaryrefslogtreecommitdiff
path: root/abfall_spermüll/get.sh
blob: 3cb4b6f7c2a044e5b0740147109cbf7acc8cacad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

fetch_tour() {
    tourId=$1
    curl "http://www.abfallwirtschaft-ortenaukreis.de/tourSearch.php?id=53&lang=de&action=showTour&muellID=8&tour=$tourId" 2>/dev/null |
        iconv -f ISO-8859-1 -t utf8
}

parse_tour() {
    tourId=$1
    tmp=`mktemp`
    fetch_tour $tourId > "$tmp"
    bereich=`sed -n -e 's/.*Bereich: \([^<]\+\).*/\1/p' < "$tmp"`
    for datum in `sed -n -e 's/\s\+\w\+, \([0-9]\{2\}\)\. \(\w\+\) \([0-9]\{4\}\).*/\1.\2.\3/p' < "$tmp"`; do
        python -c "import time,locale; locale.setlocale(locale.LC_TIME, 'de_DE.utf8'); print time.strftime('%F', time.strptime('$datum', '%d.%B.%Y')), '$bereich'"
    done
    rm "$tmp"
}

for tourId in `seq 1 9000`; do
    echo tourId=$tourId >&2
    parse_tour $tourId
done