Skip to content

Instantly share code, notes, and snippets.

@gdemir
Last active December 20, 2016 12:03
Show Gist options
  • Save gdemir/2c356028cab42e6ba8fb to your computer and use it in GitHub Desktop.
Save gdemir/2c356028cab42e6ba8fb to your computer and use it in GitHub Desktop.
image download
#!/bin/sh
echo "url? :"
read url
echo "isim? :"
read directory
wget $url
imagelinks=`cat index.html | grep -o '<img data-src="http[^"]*"' | sed 's/<img data-src="//;s/"$//'`
imagereplies=`cat index.html | grep -o 'data-cevap="[^"]*"' | sed 's/data-cevap="//;s/"$//'`
rm -rf index.html
#for imagelink in $imagelinks; do
#wget $imagelink;
#done
i=1
for imagerelpy in $imagereplies; do
echo $i - $imagerelpy >> $directory.txt;
i=$((i+1))
done
#!/bin/bash
echo -DOWNLOAD_URL "Download URL ?"
read DOWNLOAD_URL
echo $DOWNLOAD_URL
echo -BASE_URL "Base URL ?"
read BASE_URL
echo $BASE_URL
echo -DIR "Make DIR ?"
read DIR
mkdir $DIR
cd $DIR
OLDIFS=$IFS
IFS=$'\n'
a_tags=$(curl $DOWNLOAD_URL | grep -Po '(?s)<img.*src.*alt.*/>')
# for line in $a_tags; do
# printf "$line\n" | grep -Po '(?s)src.*alt.*"' | awk -F\" '{print "link: " $2"\ntitle: "$4}'
# printf "================================================================================\n"
# done
for line in $a_tags; do
read src <<< $(printf "$line\n" | grep -Po '(?s)src.*alt.*"' | awk -F\" '{ print $2 }')
read alt <<< $(printf "$line\n" | grep -Po '(?s)src.*alt.*"' | awk -F\" '{ print $4 }')
wget -O $alt.jpg $BASE_URL/$src
done
IFS=$OLDIFS
#!/bin/bash
echo -DOWNLOAD_URL "Download URL ?"
read DOWNLOAD_URL
#DOWNLOAD_URL=http://www.samm.com/tr/telekom/duvar-tipi-terminasyon-kutular.html
echo $DOWNLOAD_URL
echo -BASE_URL "Base URL ?"
read BASE_URL
#BASE_URL=http://www.samm.com/
echo $BASE_URL
echo -DIR "Make DIR ?"
read DIR
mkdir $DIR
cd $DIR
imagelinks=($(curl $DOWNLOAD_URL | grep -o '<img src="http[^"]*"' | sed 's/<img src="//;s/"$//'))
image_max=${#imagelinks}
for i in $(seq 0 $image_max);
do
echo $imagelinks[$i]
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment