#!/bin/sh curl -s http://shithouse.tv/ | pup '#all_bumps li a attr{href}' > urls for url in $(cat urls) do subdomain=$(echo $url | grep -o '//[^.]*' | sed 's/^..//') html=$(curl -s "$url") filename=$(echo $html | pup '.center-inner [src] attr{src}') if [ -z "$filename" ]; then filename=$(echo $html | pup -p 'style text{}' | grep 'background-image' | grep -o '".*"' | sed 's/"//g') fi fileurl="$url$filename" echo $fileurl filepath="$subdomain/$filename" mkdir -p $subdomain curl "$fileurl" -o "$filepath" done