#1 - 2010-6-24 17:08
wudaown
昨晚rss了konachan 早上起来无比蛋疼 .. 一个一个下载很麻烦 于是就开工了

嘛 昨天分析了hongfire的某页面提取了80+个mediafire的链接 . 于是灵感是这里来的 ..

大概说下运行顺序

首先 下载页面post主页 然后查找规律 找到后通过grep awk sed等一些列工具处理得到我需要的内容

然后就调用aria2c或者wget下载壁纸 默认会建立$HOME/.konachan和$HOME/Pictures/Konachan来存放需要的资料和下载完的壁纸


壁纸挑选了原图 绝对不是预览什么的 .. 使用diff来分辨已经下载和新的图片

问题在于分类tag来分类的话 虽然能做到不过不是一般的麻烦 (毕竟是用脚本不是程序啊

而且一张图N多tag ... 于是默认使用2010-06-24-4来分类了 .. 按照日期

最后丢到cron里去每小时执行一次

#/bin/bash

dir=$HOME/.konachan/

storedir=$HOME/Pictures/Konachan/

if [ -e "${dir}"  ]
        then
        echo -e "Directory exist"
        else
                mkdir "${dir}"
                fi

if [ -e "${storedir}" ]
        then
        echo -e "Place to store ready"
        else
                mkdir "${storedir}"
                fi

wget http://konachan.com/post -O "${dir}"post

fold=$(date +%F-%w)

mkdir "${storedir}""${fold}" 2> /dev/null

touch "${dir}"store.old

mv "${dir}"store "${dir}"store.old

org=$(cat "${dir}"post | grep konachan.com/post/show | sed 's/.*pl //g' | sed 's/<.*//g')

echo "${org}" > "${dir}"store

comp=$(diff "${dir}"store "${dir}"store.old | grep \< | sed 's/<//g')

if [ -z "${comp}" ]
        then
        echo -e "No New wallpaper"
        else
                echo -e "Downloading New Wallpaper"
               
                echo "${comp}" | while read item
                        do
                                getpic=$(cat "${dir}"post | grep "${item}" | sed 's/.*pl //g' | grep kuro.hanyuu.net/image | sed 's/.*f="//g' | sed 's/".*//g')
                                for  var in $getpic
                                do
                                                aria2c $var
                                                done
                                                done
                                                fi

file=$(ls Konachan* 2> /dev/null )

echo "${file}" | while read image
        do
                mv "${image}" "${storedir}""${fold}" 2> /dev/null
                done

rm "${dir}"post


代码简陋 大家看看就好

保存之后chmod +x xxx就可以了 ..

上面贴的是下载konachan.com的 .. 其实萌妹也差不多 打包丢下面

下载点我 (别动我 缩
#2 - 2010-6-24 18:45
(旅行真好。)
这组名太好~
#3 - 2010-6-24 19:19
(突然感觉自己老了)
以前这样批量过萌妹,发现硬盘实在抗不住……
#4 - 2010-6-24 20:14
BBCode给个等宽字体多好
#5 - 2010-6-25 10:53