| View previous topic :: View next topic |
| Author |
Message |
Mentolboy Guest
|
Posted: Wed Apr 03, 2002 3:00 pm Post subject: |
|
|
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]]
}
[ This Message was edited by: Mentolboy on 2002-04-03 12:07 ] |
|
| Back to top |
|
 |
|
|
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
|
|