Last active
September 1, 2019 09:18
-
-
Save seb-jones/f5c25453f69ec0bad53d35a733694d8e to your computer and use it in GitHub Desktop.
Pokemon Fusion Scraper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Pokemon Fusion Scraper | |
# | |
# Simple script that uses curl to grab all the images from pokemon.alexonsager.net. | |
# Each image is given a meaningful name. | |
# | |
# Requires Curl | |
if [ ! -d images ] | |
then | |
mkdir images | |
fi | |
NUMBER_OF_POKEMON=151 | |
for (( i = 1; i <= $NUMBER_OF_POKEMON; i++ )); do | |
for (( j = 1; j <= $NUMBER_OF_POKEMON; j++ )); do | |
if [ $i -eq $j ] | |
then | |
continue | |
fi | |
HTML=$(curl -s "https://pokemon.alexonsager.net/$i/$j") | |
COMBINED_NAME=$(echo $HTML | | |
grep -oE '<div id="pk_name">([^<]+)</div>' | | |
sed -E -e 's!<div id="pk_name">([^<]+)</div>!\1!') | |
NAMES=$(echo $HTML | | |
grep -oE '<option selected="selected" value="[0-9]{1,3}">([^<]+)</option>' | | |
sed -E -e 's!<option selected="selected" value="[0-9]{1,3}">([^<]+)</option>!\1!') | |
FIRST_NAME=$(echo $NAMES | cut --fields=1,1 -d ' ') | |
SECOND_NAME=$(echo $NAMES | cut --fields=2,2 -d ' ') | |
IMAGE_NAME="images/$COMBINED_NAME-$FIRST_NAME-$SECOND_NAME-$i-$j.png" | |
curl -s "https://images.alexonsager.net/pokemon/fused/$i/$i.$j.png" -o "$IMAGE_NAME" | |
echo $IMAGE_NAME | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment