Posted to tcl by wIreS at Tue Jul 24 11:57:18 GMT 2007view pretty

#!/bin/sh
exec tclsh8.4 "$0" ${1+"$@"}
package require tdom
package require http
set url "http://localhost"
set page [::http::data [::http::geturl $url]]
set doc [dom parse -html $page]
set root [$doc documentElement]
set node [$root selectNodes {//html[1]/body[1]/div[3]/p[1]/span[3]}]
set text [[[lindex $node 0] childNodes] nodeValue]
puts "[string trim $text]"

Comments

Posted by wIrEs at Tue Jul 24 12:06:25 GMT 2007 [text] [code]

invalid command name "" while executing "[lindex $node 0] childNodes" invoked from within "[[lindex $node 0] childNodes] nodeValue" invoked from within "set text [[[lindex $node 0] childNodes] nodeValue]" (file "./http" line 11)

Posted by mjanssen at Tue Jul 24 13:07:56 GMT 2007 [text] [code]

#!/bin/sh exec tclsh8.4 "$0" ${1+"$@"} package require tdom package require http set url "http://localhost" set page [::http::data [::http::geturl $url]] set doc [dom parse -html <myroot>$page</myroot>] set root [$doc documentElement] set nodes [$root selectNodes {//div[@id="keys"]/p/span}] foreach node $nodes {puts [$node asText]}