fnan 写了:我就是我2 写了:
接受批评. 当时确实没有想到这个问题.页面分析真是失败.哎
代码: 全选
sed -rn '/>公告<\/b>/,/>主题<\/b>/d;/<b>置顶.<\/b>/d;/<b>投票.<\/b>/d;s/.*"topictitle">(.{1,10}).*<\/a>.*/\1\.../p' forum.dat | head -5 >title.dat
#然后作者名字匹配又如何?
得重新设计算法.
以前没注意到"置顶"和"公告"的小图标
不用理会投票什么的. 只有两种特殊主题 announce 和 sticky
只需要统计两种小图标一共出现的次数就行了. 当然要减2 ,因为最下面的是示例 "置顶"和"公告" 各有一
# 不登陆,抓到的页面,主题的小图标都是 灰色 即"已读"
[bash]
#!/bin/bash
[ -f ~/.forumstatus.dat ] || touch ~/.forumstatus.dat
old=`cat ~/.forumstatus.dat`
[ -d /tmp/forumshell ] || mkdir /tmp/forumshell
cd /tmp/forumshell
while : ; do
curl -s "
viewforum.php?f=21" 2>/dev/null >forum.dat
delnum=$(expr $(grep -c announce_read.gif forum.dat ) + $(grep -c sticky_read.gif forum.dat ) - 2)
shownum=5
begin=`expr $delnum + 1`
end=`expr $delnum + $shownum`
sed -rn 's/.*"topictitle">(.{1,10}).*<\/a>.*/\1\.../p' forum.dat | sed -n "$begin,$end"p > title.dat
sed -nr 's/.*class="topicdetails"><.*>(.*)<\/a>$/\1/p' forum.dat | sed -n "$begin,$end"p >name.dat
sed -nr 's/.*"topicdetails" style.* (.*)<\/p>/@\1/p' forum.dat | sed '1~2d' | sed -n "$begin,$end"p >last.dat
new=`awk '{printf $0 ;getline <"name.dat";print}' title.dat | awk '{printf $0 ;getline <"last.dat";print}'`
[ "$new" = "$old" ] || notify-send "$new"
old="$new"
echo "$old" >~/.forumstatus.dat
sleep 300
done
[/bash]
可能还是失败...
