如何使用带有示例
的TCL http包捕获html表我尝试了一个示例,但它很简单地从会话中退出。
package require http
package require base64
set auth "Basic [base64::encode XXXX:XXXXX]"
set headerl [list Authorization $auth]
set query "http://100.59.262.156/"
set tok [http::geturl $query -headers $headerl]
set res [http::data $tok]
http::status $tok
# After login into the session, i am moving one page another web page
set goquery [http::formatQuery "http://100.59.262.156/web/sysstatus.html"]
# After this i am log out from the session. I am unable to find reason.
set tok [http::geturl $query -query http://100.59.262.156/web/sysstatus.html]
set res [http::data $tok]
# After this i will get a table output i need capture this table
# how to capture tables using
http::status $tok
由于
Malli
答案 0 :(得分:0)
我在这里看到一些误解:
http::geturl
返回的令牌。您可以使用http::cleanup $token
执行此操作。否则会导致内存泄漏。http::formatQuery
用于POST或GET参数,不用于URL(您可以将其用于查询URL部分,但不能用于整个URL)。放弃。因为我不知道你的网站返回什么,我不能告诉你如何解析它,但是这里有一个开始的脚本:
package require http
package require base64
package require tdom
set auth "Basic [base64::encode XXXX:XXXXX]"
set headerl [list Authorization $auth]
set url "http://100.59.262.156/web/sysstatus.html"
set tok [http::geturl $url -headers $headerl]
# TODO: Check the status here. If you get a 403, the login information was not correct.
set data [http::data $tok]
# Important: cleanup
http::cleanup $tok
# Now parse it
dom parse -html $data doc
# Search for the important stuff, walk over the dom... to the the important information