egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with egghelp.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ryal
Voice


Joined: 12 May 2005
Posts: 35

PostPosted: Thu Dec 15, 2005 1:17 pm    Post subject: Help with egghelp.tcl Reply with quote

Hi !
Im trying to parse the content of a webpage but it doesnt work (it does tho with some webpages but not with www.google.com).
Heres the code i use:

Quote:

proc parse_proc { nick uhost handle arg } {
global mychan sock

set d [date:offset [clock seconds] %m%d%y]
set url "http://www.google.com"
set target $nick
set sock [egghttp:geturl $url [list parseinfo $target $url] -timeout 600]
puthelp "PRIVMSG $target :$url"
}

proc parseinfo {target url sock} {
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
puthelp "PRIVMSG $target :hello"
puthelp "PRIVMSG $target :$headers"
puthelp "PRIVMSG $target :$body"
}


It displays the right url, "hello" and then nothing. I know body is a big variable but it should display the first line (which it does for some websites, but not with google). Of course i loaded egghelp.tcl in my *.conf and it loads alright.
What did i do wrong? i do believe the error stands in the way i call egghttp:geturl but i dont know how to fix it
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Thu Dec 15, 2005 8:21 pm    Post subject: Reply with quote

3 things:
- try using a shorter timeout than 10min Very Happy
- try using the header line "Connection: close"
- Try passing only the first line to puthelp via [string range $body 0 [string first $body "\n"]]. That saves your bot getting various errors from IRC Server and most likely getting spammed out (if it isnt trimmed to 510 bytes anyway)

Btw. headers also contain about 5-10 lines depending on HTTP server.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Dec 16, 2005 3:09 am    Post subject: Reply with quote

egghttp is outdated, do not use it

use Tcl's built-in http package instead
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
ryal
Voice


Joined: 12 May 2005
Posts: 35

PostPosted: Fri Dec 16, 2005 6:08 am    Post subject: Reply with quote

Thx for the tip, didnt know there was a built in package.
Anyway, i still get the same error (that is http::data returns an empty string, no url data). Heres the new code:


Code:

proc parse_proc { nick uhost handle arg } {
   global sock

   set url "http://www.google.com"
   set target $nick
   set sock [::http::geturl $url -command [list parseinfo $target $url] -timeout 60]
   puthelp "PRIVMSG $target :$url"
}

proc parseinfo {target url sock} {
   set body [::http::data $sock]
   ::http::cleanup $sock
   
   set body2 [string range $body 0 [string first $body "\n"]]
   puthelp "PRIVMSG $target :hello"
   puthelp "PRIVMSG $target :$body hello2"
}


It displays the url, "hello" and then "hello2" with nothing in front of it.
Any ideas?

PS: of course the timer wasnt 10' at first Wink i just wanted to know if it could be a timer pb so i put an extra large.
Thanks for your help guys!


Last edited by ryal on Tue Dec 20, 2005 12:03 pm; edited 1 time in total
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Dec 16, 2005 11:26 pm    Post subject: Reply with quote

try using it in the simpler, blocking form first - i.e. without -command switch

and use [code] tag when posting code, not [quote]
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
ryal
Voice


Joined: 12 May 2005
Posts: 35

PostPosted: Tue Dec 20, 2005 12:02 pm    Post subject: Reply with quote

I get exactly the same result without the "-command".
Could this be a bug from the http package?
PS: sorry the for quote instead of code; i just fixed it
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Dec 20, 2005 11:21 pm    Post subject: Reply with quote

nope, it's bug in your script or/and your logic
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber