I have a script to retrieve news headlines from a website - and with help from here, I've set up a check using variables so that the headlines don't repeat if there isn't a new one since the last check.
This works fine on the sites that only have one news headine on the page, however, when I try to use it on a page that has a list of headlines where there is no unique html code to identify only the newest top headline, the check system goes haywire.
It gets the top line, then on the next check, it sees that it is the same as before and instead of stopping, goes onto the next story down and sends that to the channel. On the next check it goes back and sends the first story and so it carries on between the top 2 headlines.
Is there a way I can force the script to not go past the first line I'm trying to retrieve in the script so this back-and-forth can't happen?
Here's the proc I'm using:
Code: Select all
proc getrtr {sock} {
global rtrurl rtrold
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
egghttp:cleanup $sock
foreach line [split $body \n] {
if {[string match "*52_*" $line]} {
set rtr [gettok $line 2 62]
set rtr [gettok $rtr 0 60]
set rtrurl [gettok $line 5 34]
if ($rtr != $rtrold)} {
putserv "PRIVMSG #channel :/0034,4 /0031,15 $rtr /00314,14 /003"
} else {
set rtrold $rtr
}
}
}
}