Created
July 23, 2013 12:49
-
-
Save mebius01/6062099 to your computer and use it in GitHub Desktop.
Объединённые пара скриптов, имеющие одинаковое предназначение, но работающих на разных сайтиках
This file contains hidden or 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 | |
# 23.07.13 | |
# http://habrahabr.ru/post/127084/ Взаимодействие bash-скриптов с пользователем | |
# Собранные в кучу два скрипта https://gist.github.com/mebius01/6054482 и https://gist.github.com/mebius01/6061111 | |
set -e | |
ME=`basename $0` | |
function print_help { | |
echo "Скрипт тащи картинки с сайтов http://www.cuded.com/, http://2photo.ru/" | |
echo "Использование: $ME -options" | |
echo "Параметры:" | |
echo "c - http://www.cuded.com/" | |
echo "2 - http://2photo.ru/" | |
} | |
function cuded { | |
echo "Введите адрес ссылки:" | |
read URL && | |
wget $URL && | |
MKDIR=`cat index.html | sed -n '/<title>/p' | cut -d'>' -f 2 | cut -d '|' -f1` && | |
mkdir "$MKDIR" && | |
ECHO=`echo "$MKDIR"` && | |
CAT=`cat index.html | sed -n '/class="sdj_pinterest_wrap"><img src=/p' | sed 's/<div class="sdj_pinterest_wrap"><img src="//g' | sed 's/" alt=""/\n/g' | sed G | sed '/>/d' | sed '/^$/d'` && | |
(cd "$ECHO" && for i in "$CAT" | |
do | |
wget $i | |
done) | |
rm index.html | |
} | |
function 2photo { | |
http="http:" | |
echo "Введите адрес ссылки:" | |
read URL && | |
wget $URL && | |
CATID=`echo "$URL" | cut -d'/' -f6` && | |
MKDIR=`cat "$CATID" | sed -n '/<h1>/p' | cut -d'>' -f2 | cut -d'<' -f1` && | |
mkdir "$MKDIR" && | |
ECHO=`echo "$MKDIR"` && | |
CAT=`cat "$CATID" | sed -n '/;" href="/p' | sed 's/><img /\n/g' | sed '/>/d' | cut -d'"' -f4` && | |
echo "$CAT" | |
(cd "$MKDIR" && | |
for i in $CAT | |
do | |
wget $http$i | |
done | |
) | |
rm "$CATID" | |
} | |
if [ $# = 0 ]; | |
then | |
print_help | |
fi | |
while getopts ":c2" opt ; | |
do | |
case $opt in | |
c) cuded | |
;; | |
2) 2photo | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment