This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

constraining socket data

Old posts that have not been replied to for several years.
Locked
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

constraining socket data

Post by NewzUK »

Hi - This relates sort of to a previous script I've sought help on - please excuse the long explaination!
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 
        } 
      } 
    } 
} 
Thanks for any help! :-?
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Break from the loop and procedure by calling "return" where you want it to exit...
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks strikelight - have put a return in at the end ( I think that's the right position?), and for the individual calls, it stops and just sends the top line. But the next time it runs, if that first story hasn't changed, instead of stopping, it gets the second oldest story. It's hard to explain...not sure how else I can demonstrate?
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Try putting the return after this line:

putserv "PRIVMSG #channel :/0034,4 /0031,15 $rtr /00314,14 /003"
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

just tried it and still no luck...
this is what the problem looks like:
[22:40:16] <iNews> [GE] GE 'CONFIDENT' OF 10%-15% EPS GROWTH FOR 2005
[22:40:47] <iNews> [GE] GE REVISES FULL-YEAR EARNS RANGE TO $1.55-$1.60/SHR
[22:41:16] <iNews> [GE] GE 'CONFIDENT' OF 10%-15% EPS GROWTH FOR 2005
[22:41:48] <iNews> [GE] GE REVISES FULL-YEAR EARNS RANGE TO $1.55-$1.60/SHR
[22:42:16] <iNews> [GE] GE 'CONFIDENT' OF 10%-15% EPS GROWTH FOR 2005
[22:42:46] <iNews> [GE] GE REVISES FULL-YEAR EARNS RANGE TO $1.55-$1.60/SHR

top 2 headlines just repeat and dosn't stop at the first one, even with the check to see if it's old or not...
aghrrr
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Ooops what about after the else? (but still inside the main if part)
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

then it didnt send the msg to the channel...

but I've solved the problem by making a separate proc for the msg to the channel, and triggering that after the setting of the variables - now it's not repeating :)

thanks for the help though!
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
Locked