LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 753|回复: 2

我写了个baidu.com的top500的自动下载脚本

[复制链接]
发表于 2006-7-18 15:54:12 | 显示全部楼层 |阅读模式
#!/bin/bash

# version-1.1
# Leo lee lxz3002@yahoo.com.cn
# 2006.07.15
#

TEMP_DIR=top500
TOP500_PAGE=top500.page
TOP500_LIST=top500.list
SEARCH_PAGE=search.page
SEARCH_LIST=search.list


echo "------www.baidu.com top500 auto downloader------"
export LC_ALL=zh_CN

# create a temprary directory
if [ -e $TEMP_DIR ]
then
        echo "$TEMP_DIR exists"
else
        mkdir $TEMP_DIR

        if [ "$?" -eq "1" ]
        then
                echo "mkdir failed! "
                exit 1
        fi
fi

cd $TEMP_DIR

echo "wgetting top500 page to $TOP500_PAGE"
echo
wget http://list.mp3.baidu.com/topso/mp3topsong.html -O $TOP500_PAGE

echo -n "translating $TOP500_PAGE to $TOP500_LIST ... "
cat $TOP500_PAGE | sed -e '/"http:\/\/mp3.baidu.com\/m?tn=baidump3.*+.*"/!d' -e 's/^.*href="//g' -e 's/" *target.*$//g' | gawk 'BEGIN{ FS="\"" }; { print $1 }' > $TOP500_LIST
echo "Good :-)"

# top500
for CUR in `cat $TOP500_LIST`
do
        wget $CUR -O $SEARCH_PAGE
        #get search page
        echo -n "Translating $SEARCH_PAGE to $SEARCH_LIST ... "
        cat $SEARCH_PAGE | grep '^<a.*http://220\.181\.27\.54' | sed -e 's/^.* title.*http:\/\///g' -e 's/".*$//g' | gawk 'BEGIN{FS=" "};{print $1}' > $SEARCH_LIST
        echo "Good :-)"

        for INST in `cat $SEARCH_LIST`
        do
                if wget  $INST
                then
                        break
                fi
        done
done

# Cleaning up temp files
rm -f $TOP500_PAGE
rm -f $TOP500_LIST
rm -f $SEARCH_PAGE
rm -f $SEARCH_LIST

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
 楼主| 发表于 2006-7-18 17:32:48 | 显示全部楼层
请各位大虾帮忙测试指点。希望能做的更好。
回复 支持 反对

使用道具 举报

发表于 2007-1-14 20:06:54 | 显示全部楼层
大哥,中文名都不正确,叫人怎么看啊?

%CC%FD%C2%E8%C2%E8%B5%C4%BB%B0+%D6%DC%BD%DC%C2%D7
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表