blob: a9fa46bcf1647a1521fd4563b1c56bbf092468dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/bash
# I would like to interject for a moment.
# text datei mit pokemons
FILE="test.txt"
# url zum (poke-)wiki
WIKI="http://pokewiki.de/"
# speicherpfad für heruntergeladenen webseiten
SAVEPATH="./"
### CONF ENDE ###
# teste ob textdatei angegeben wurde
if [ ! -f $FILE ]; then
echo "'$FILE' not a file." 1>&2
exit 1
fi
# teste ob wiki url angegeben wurde
if [ -z "$WIKI" ]; then
echo "No URL given." 1>&2
exit 1
fi
# bestimme anzahl der schleifen iterationen
LINES=$(wc -l "$FILE" | cut -d ' ' -f 1)
if [ $LINES == 0 ]; then
echo "$FILE has 0 lines." 1>&2
exit 1
fi
for ((i=1;i<=$LINES;i++)); do
# lese pokemon aus der textdatei aus
POKEMON=$(cut -f2 -s "$FILE" | sed -n ${i}p)
# teste, ob datei früher schon einmal heruntergeladen wurde
if [ -f $POKEMON.txt ]; then
read -p "$(tput setaf 1)Warnung! $(tput bold)$POKEMON.txt$(tput sgr0) $(tput setaf 1)existiert schon. Sollen die Informationen überschrieben werden?$(tput sgr0) [Y/n] " answer
if [ "x$answer" == "xn" ]; then
continue
fi
fi
echo "Lade Informationen zu $(tput setaf 3)'$POKEMON'$(tput sgr0) runter."
# speichere datei in textdatei
elinks -dump "${WIKI}${POKEMON}" > ${SAVEPATH}${POKEMON}.txt
done
|