用于养眼的脚本

weixin_38102041 weixin_38102041 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

#!/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
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部