A bit of script for downloading images from a website
So I wanted to download only images from this one website for archival usage. After looking at all ready available page, I couldn't find anything suiting for my purpose. So I decided to throw in a little shell-script.
It went on as follows: The pages are incremental in index. So I can use a while loop to fetch all pages one by one. Done.
Need to fetch the page. Wget is fine. Done.
Then I need to look for the image URL in retrieved HTML. Hmm. Bit of grep with cut does that. Done.###########################
#!/bin/bash
export https_proxy=""
count=11000
while [ $count -gt 10800 ]
do
echo "Downloading page $count..."
content=$(wget https://www.mygallery.com/photo/$count -q -O -)
#echo $content
echo "Page downloaded!"
line=$(echo $content | grep -b -o "class=\"main-photo\"")
offset=$(echo $line| cut -d : -f1)
((offset1=offset+50))
img="https://www.mygallery.com/resized/"$(echo $content | cut -c$offset-$offset1 | tail -c18)
echo "Getting Image: "$img"..."
wget $img -q
((count=count-1))
#echo "count: $count"
done
exit 0
###########################
Comments
Post a Comment