免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2061 | 回复: 0
打印 上一主题 下一主题

用于养眼的脚本 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-03-22 14:26 |显示全部楼层 |倒序浏览
#!/bin/sh
pages=${1:-5}


mycollect()
{
LC_ALL=C sed -n '/<a href=bbstcon\?board=LoveBridge\&reid=/{
s/>[^<]*</></g;s/<..>//g;
s/<a href=bbsqry\?userid=[^>]*>//g;
s/<[^>]*font[^>]*>//g; s/<[^>]*table>//g;
s/<a href=bbstopcon\?board=LoveBridge\&file=[^>]*>//g;
s/<a href=/http:\/\/bbs.sjtu.edu.cn\//g;
s/>/\
/g;
s/\n$//;
p;}'
tmp.htm
}


theaddr='http://bbs.sjtu.edu.cn/bbstdoc?board=LoveBridge'
echo "Collecting the addresses..."
wget -q -O tmp.htm $theaddr
shu=$(LC_ALL=C sed -n '/>上一页<\/a> <a href=bbsnot\?board=LoveBridge>进板画面<\/a>/{s/^.*page=//;s/>.*$//;p;q;}' tmp.htm)

mycollect > myaddr.txt
thepage=0
while [ $thepage -lt $pages ]
do
wget -q "http://bbs.sjtu.edu.cn/bbstdoc?board=LoveBridge&page=$(($shu - $thepage))" -O tmp.htm
mycollect >> myaddr.txt
thepage=$(($thepage + 1))
done

lines=$( wc -l myaddr.txt | awk '{print $1}')
theline=1
true > index.htm
while [ $theline -le $lines ]
do
theimgaddr=$(sed -n ${theline}'{p;q;}' myaddr.txt)
echo "($theline of $lines) Analyzing "$theimgaddr
wget -q "$theimgaddr" -O tmp.htm
LC_ALL=C sed -n '/<IMG SRC/{s/="\//="http:\/\/bbs.sjtu.edu.cn\//g; s/^/<a href="'$(echo "$theimgaddr" | LC_ALL=C sed 's/\//\\\//g;s/\?/\\&/; s/\&/\\&/;')'">/; s/$/<\/a>/;p;}' tmp.htm >> index.htm
theline=$(($theline + 1))
done

sort -u -k 3,3 index.htm > tmp.htm
mv tmp.htm index.htm
echo "Analyses done."
echo
echo $(wc -l index.htm | awk '{print $1;}')" photoes with source links are collected in \"index.htm\". You can open it in your explorer and enjoy!"




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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP