Basically, I have zero idea how to even start this. I wanna make a server status script for my bot that would read off a webpage (http://chronicle.ubi.com/). Now if you view that webpage, you will see on the right about 10 servers. I would like to be able to get the status for the one server called Deception. So basically i just wanna see if beside Deception, if it says UP or Down.
I have got the http script loaded, but after trying the parsing I get totally lost, if someone can provide some insight, that would be greatly appreciated. Thanks.
the problem with lynx is that there is no real timeout
i had some of my scripts with lynx too, but when the webpage to slow etc the exec just took some minutes -> bot times out....
proc status_callback {sock} {
global inifilestatus
set data [egghttp:data $sock]
egghttp:cleanup $sock
regsub -all "\n" $data "" data
regsub -all "<br>" $data "\n" data
foreach line [split $data \n] {
if {[string match "*Deception*Up*" $line]} {
set item [join [lindex [split $line] 1]]
ini_write $inifilestatus server status $item
}
if {[string match "*Deception*Down*" $line]} {
set item [join [lindex [split $line] 1]]
ini_write $inifilestatus server status $item
}
return 0
}
}
Ok so when it checks the status, its supposed to use my ini_write proc. But the problem is, is its not even getting the line, I'm not sure If its even getting the page properly.
proc status_callback {sock} {
global inifilestatus
set data [egghttp:data $sock]
egghttp:cleanup $sock
regsub -all "\n" $data "" data
regsub -all "<br>" $data "\n" data
foreach line [split $data \n] {
if {[string match "*Deception*Up*" $line]} {
set item [join [lindex [split $line] 1]]
ini_write $inifilestatus server status $item
}
if {[string match "*Deception*Down*" $line]} {
set item [join [lindex [split $line] 1]]
ini_write $inifilestatus server status $item
}
return 0
}
}
Ok so when it checks the status, its supposed to use my ini_write proc. But the problem is, is its not even getting the line, I'm not sure If its even getting the page properly.
set sock [egghttp:geturl chronicle.ubi.com/ status_callback]
set server_status [ini_read $inifilestatus server status]
But thats totally wrong as I've never ever used this http stuff in a script before so i'm totally lost.
Because egghttp works in non-blocking mode (ie. it won't freeze up your bot), your 'set server_status' line will most likely be called before the callback proc gets called.. If you want to set anything, it will have to be within the callback proc itself... To verify it is working, add 'putlog' statements in your callback proc, and stay in your bot's partyline while the bot tries to connect to the site and watch what is going on.
Are there any good tutorials on the subject parsing files/html
???
if there is i would reallt like an url.
or if someone could help me that would be good too.
prefrably real time like chat on ICQ or IRC..
GodOfSuicide wrote:the problem with lynx is that there is no real timeout
i had some of my scripts with lynx too, but when the webpage to slow etc the exec just took some minutes -> bot times out....
what would be the best method here, does fetch or wget have a good timeout?