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.

tcl error in script that picks info from html file

Old posts that have not been replied to for several years.
Locked
M
Mentolboy

Post by Mentolboy »

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 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]]

}

<font size=-1>[ This Message was edited by: Mentolboy on 2002-04-03 12:07 ]</font>
Locked