Created
January 8, 2021 17:04
-
-
Save frezbo/c8642b50a84e896e92f52b84f8bd6ef2 to your computer and use it in GitHub Desktop.
mandalorian wallpapers
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 | |
set -eu -o pipefail | |
NUM_OF_PAGES="6" | |
DOWNLOAD_DIR="/tmp/mando" | |
mkdir -p "${DOWNLOAD_DIR}" | |
BASE_URL="https://wall.alphacoders.com/by_sub_category.php?id=313409&name=The+Mandalorian+Wallpapers" | |
for ((i = 1; i <= NUM_OF_PAGES; i++)); do | |
PAGE_URL="${BASE_URL}&page=${i}" | |
HTML_DATA=$(curl -sSL "${PAGE_URL}") | |
IMAGES_LIST=$(grep -A 1 -e "TV Show The Mandalorian" -e "The Mandalorian HD Wallpapers" <<< "${HTML_DATA}" | grep -oE "https://images[0-9]{0,1}.alphacoders.com/[0-9]{3}/thumb-[0-9]{3,4}-.*.jpg") | |
IMAGES_LIST=$(uniq <<< "${IMAGES_LIST}") | |
IMAGES_LIST="${IMAGES_LIST//thumb-350-/}" | |
echo "processing for page ${i}" | |
echo "images in page ${i} is: $(wc -l <<< "${IMAGES_LIST}")" | |
( | |
cd "${DOWNLOAD_DIR}" || true | |
for IMAGE in ${IMAGES_LIST}; do | |
[[ -e $(basename "${IMAGE}") ]] && continue | |
curl -sSLO "${IMAGE}" | |
done | |
) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment