Skip to content

Instantly share code, notes, and snippets.

@Raymo111

Raymo111/dilbert.sh

Created Oct 25, 2019
Embed
What would you like to do?
Dilbert Crawl
#!/bin/bash
start=$1
case "$2" in
"") end=$1 ;;
*) end=$2 ;;
esac
start=$(date -d $start '+%Y-%m-%d')
end=$(date -d $end '+%Y-%m-%d')
[ -d Dilberts ] || mkdir Dilberts
cd Dilberts
while [[ $(date -d $start +%s) -le $(date -d $end +%s) ]]
do
img=$(curl -s https://dilbert.com/strip/$start | grep "img-responsive img-comic")
img=${img#*src=\"}
img=${img%\"*}
img=https:$img
echo "$start: $img"
wget -qct=2 --retry-connrefused -O $start $img
start=$(date -d "$start + 1 day" '+%Y-%m-%d')
done
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment