Skip to content

Instantly share code, notes, and snippets.

@seb-jones
Last active September 1, 2019 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seb-jones/f5c25453f69ec0bad53d35a733694d8e to your computer and use it in GitHub Desktop.
Save seb-jones/f5c25453f69ec0bad53d35a733694d8e to your computer and use it in GitHub Desktop.
Pokemon Fusion Scraper
#!/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