Make the scrapper a little more readable
Maybe myself from the past was right about it. I really might have grown stronger. :D
This commit is contained in:
@@ -26,11 +26,12 @@ fi
|
|||||||
# 'cat' will read the file and pipe its output to 'sed'. 'sed'
|
# 'cat' will read the file and pipe its output to 'sed'. 'sed'
|
||||||
# will filter the html searching for the Pokémon name and its
|
# will filter the html searching for the Pokémon name and its
|
||||||
# image url. 'sed' will output the Pokémons in this format:
|
# image url. 'sed' will output the Pokémons in this format:
|
||||||
# "<POKEMON_NAME>=<POKEMON_URL>".
|
# "<POKEMON_NAME>=<POKEMON_URL>". And the output of 'sed' will be
|
||||||
# Then, the output of 'sed' goes into the while loop, which will
|
# stored in a variable we will use later.
|
||||||
# read the output one line at a time. Within the while loop, I
|
# Then, the content of the variable will be read one line at a
|
||||||
# extract the pokemon name and the url from the read line. And
|
# time in the for loop. Within the for loop, I extract the pokemon
|
||||||
# then, it just downloads the url to a file.
|
# name and the url from the read line. And then, it just downloads
|
||||||
|
# the content of the url to a file.
|
||||||
# Again... I'm sorry for all the trouble. But I hope you will
|
# Again... I'm sorry for all the trouble. But I hope you will
|
||||||
# grow stronger and may be able to turn this code into something
|
# grow stronger and may be able to turn this code into something
|
||||||
# more readable.
|
# more readable.
|
||||||
@@ -38,10 +39,12 @@ fi
|
|||||||
# Kind regards,
|
# Kind regards,
|
||||||
# Yourself from the past.
|
# Yourself from the past.
|
||||||
|
|
||||||
|
pokemon_images=$(
|
||||||
cat "$scrap_folder/$bulbapedia_page_name" | \
|
cat "$scrap_folder/$bulbapedia_page_name" | \
|
||||||
sed -nr 's;^.*<img alt="(.*)" src="(http://cdn.bulbagarden.net/upload/.*\.png)" width="40" height="40" />.*$;\1=\2;p' | \
|
sed -nr 's;^.*<img alt="(.*)" src="(http://cdn.bulbagarden.net/upload/.*\.png)" width="40" height="40" />.*$;\1=\2;p' \
|
||||||
while read line
|
)
|
||||||
do
|
|
||||||
|
for line in $pokemon_images; do
|
||||||
pokemon_name="${line%=*}"
|
pokemon_name="${line%=*}"
|
||||||
pokemon_url="${line#*=}"
|
pokemon_url="${line#*=}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user