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.

egghttp again - [SOLVED] (used a different method)

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

egghttp again - [SOLVED] (used a different method)

Post by SaPrOuZy »

hi there

i've written the following script :

Code: Select all

bind pub - !bleh  check_page

proc check_page {nick uhost handle chan arg} {

	puthelp "privmsg #bleh : ***************getting page"
	set sock [egghttp:geturl www.whatismyip.org/ get_score]
	puthelp "privmsg #bleh : ***************finished page"
}

proc get_score {sock} {

	puthelp "privmsg #bleh : entered get_score"
	set buffer [egghttp:data $sock]
	puthelp "privmsg #bleh : $sock"
	puthelp "privmsg #bleh : $buffer"
	
	egghttp:cleanup $sock
	set x 0
	foreach line [split $buffer "\n"] {
		      	inc x 1
		      	puthelp "PRIVMSG #bleh : $x $line"
	}
	puthelp "privmsg #bleh : left get_score"
}
when i trigger it, i get the following:
[21:32] <@Reverence> ***************getting page
[21:32] <@Reverence> ***************finished page
[21:32] <@Reverence> entered get_score
[21:32] <@Reverence> 9
[21:32] <@Reverence>
[21:32] <@Reverence> left get_score
any idea why the data gotten is empty?
thanks.
Last edited by SaPrOuZy on Mon Jun 19, 2006 3:18 am, edited 1 time in total.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Nope, sorry:
~$ telnet www.whatismyip.org 80
Trying 206.176.224.3...
Connected to am3.am.net.
Escape character is '^]'.
GET / HTTP/1.0

HTTP/1.0 200 OK
MIME-Version: 1.0
Date: Thu, 15 Jun 2006 08:10:42 GMT
Server: AOLserver/4.0
Content-Type: text/plain
Content-Length: 11
Connection: close

208.98.**.**Connection closed by foreign host.
~$
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...
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

so the problem isn't in the code?
i tried it initially on a different site (www.livescore.com)
with the same outcome.
that's why i thought it was from the code
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

egghttp looks for a "<" to locate the "body" of the http response... you'll have to change the output of the site to include a "<" or alter the way egghttp locates the end of the header. (all header fields (should) start with a single word that ends with a ":") Make strikelight fix it ;)
Have you ever read "The Manual"?
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

but livescore.com is a normal site with normal http code.
anyways thanks for the info, i'll try to change egghttp to give me everything and i'll deal with the dump my self.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

SaPrOuZy wrote:but livescore.com is a normal site with normal http code.
anyways thanks for the info, i'll try to change egghttp to give me everything and i'll deal with the dump my self.
There's nothing wrong with the http part...it's the part of egghttp dealing with the content that expects markup...your ip is probably the last line of [egghttp:headers $sock], so try

Code: Select all

[lindex [split [egghttp:headers $sock] \n] end]
...but i still think strikelight should make some changes to his script :) (i've sent him a PM about it)
Have you ever read "The Manual"?
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

thx for ur reply.
my main issue is not getting my ip :P
it was just an example that i tried.
what am trying is to get http://www.livescore.com
am making a script to get world cup matches scores and post them on the channel.

egghttp worked with other sites, but it seems it's not owrking with livescore.com the data i get is empty.

anyway now am going to try to exec a wget on the site , rename the file , and work on the file :D hehe
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

SaPrOuZy wrote:but livescore.com is a normal site with normal http code.
anyways thanks for the info, i'll try to change egghttp to give me everything and i'll deal with the dump my self.
You should have said so in the first place...what happens when you fetch livescore.com using your script? (it seems most of the content is on a single line - which would be impossible to transmit in a single PRIVMSG)
btw: the markup on that page sucks - have fun parsing it :twisted:
Have you ever read "The Manual"?
Post Reply