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 

tcl error in script that picks info from html file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
Mentolboy
Guest





PostPosted: Wed Apr 03, 2002 3:00 pm    Post subject: Reply with quote

this script is about requesting your personal "horocope". it takes the info from a site, see in the code which one. in the code you see only the scorpio html, once the script works, i'll put the rest in it too.
but for some dark reason, the script does not work. the script doesn't do anything...
anybody some advice???
tnx!
btw, i can't put the code in
Code:
because i put some strings between [] in my code...

#!/bin/sh
# restart using tclsh
bind pub - !h pub_horoscoop

proc pub_horoscoop {n u h c} {
exec /usr/bin/tclsh "$0" "$@"

package require http
putlog "<< $n >> !horoscoop!"
proc htmlstrip {input} {
set htmllen [string length $input];set pos 0;set on 1;set output ""
while {$pos < $htmllen} {
set char [string index $input $pos]
if {$char == "<"} {set on 0}
if {$char == ">"} {set on 1;set char ""}
if {$on == 1} {append output $char}
incr pos
}
return $output
}


set url "http://horoscope.tiscali.be/nl/scorpio.html"

set mytoken [::http::geturl $url]
set pdata [::http::data $mytoken]
set status [::http::status $mytoken]
upvar #0 $mytoken state
set meta $state(meta)
set clean [::http::cleanup $mytoken]
set nummeta [llength $meta]
set cookies ""
for {set x 0} {$x < $nummeta} {incr x} {
set mkey [lindex $meta $x]
incr x
set mval [string trimleft [lindex $meta $x]]
if {$mkey == "Set-Cookie"} {
puts "mval is ($mval)"
append cookies "Cookie "
append cookies "$Version=1;[lindex $mval 0] "
}
}
set cookies [string trimright $cookies]
set last [string length $cookies]
if {[string index $cookies end] == ";"} {set cookies [string range $cookies 0 [expr $last -2]]}

#puts "cookies are ($cookies)"

if {$status == "timeout"} {puts "der is lag bij de site, probeer straks opnieuw"; exit}

regexp {<br><div align="JUSTIFY"><font face="Arial" size="-1">([^<]+)</font>} $pdata a b

puts [join [split $b n]]

}

[ This Message was edited by: Mentolboy on 2002-04-03 12:07 ]
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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