entry .entry
button .but -font Verdana -text "Search" -command "gbrank Robbz"
proc gbrank {text} {
if {[llength [split $text ""]]==0} {label .error -text "please type an ID!" ;pack .error ;return}
set sock [socket www.gunbound.net 80]
fconfigure $sock -buffering line
puts $sock "GET /rank/rank_s.asp?search_id=$text HTTP/1.1"
puts $sock "Host: www.gunbound.net"
puts $sock "Accept: */*"
puts $sock "Referer: www.gunbound.net/rank/rank_s.asp?search_id="
puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"
puts $sock "Pragma: no-cache"
puts $sock "Cache-Control: no-cache"
puts $sock "Connection: close"
puts $sock ""

flush $sock

while {![eof $sock]} {
gets $sock line
regsub -all {\t} $line "" line
if {[regexp -all {<td colspan=5 align="center"><b>No data found for the ID</b></td>} $line]} {
set noid 1
}
if {[regexp -all {<td width="61" align="center">(.*?)} $line]} {
regsub -all {(<.+?>)} $line "" line
set gbinfo(rank) "[string trimleft $line [format %c 32]]"
}
if {[regexp -all {<td width="47" align="center"><img src="../images/(.*?)"} $line _ level]} {
set gbinfo(level) "[string trimleft $level [format %c 32]]"
}
if {[regexp -all {<td width="70" align="center">(.*?)</td>} $line _ guild]} {
set gbinfo(guild) "[string trimleft $guild [format %c 32]]"
}
if {[regexp -all {<td width="100" align="center">(.*?)</td>} $line _ id]} {
set gbinfo(id) "[string trimleft $id [format %c 32]]"
}
if {[regexp -all {<td width="186" align="center" height="20">(.*?)</td>} $line _ gp]} {
set gbinfo(gp) "[string trimleft $gp [format %c 32]]"
}
}
close $sock

if {[info exists noid]} {puts "No data found for the ID";return}

if {$gbinfo(guild) == "--"} { set gbinfo(guild) "NONE" } 

set gbinfo(level) [string map {"rank_0.gif" "Red Wand" "rank_-1.gif" "Diamond Wand" "rank_-2.gif" "Blue Dragon" "rank_-3.gif" "Red Dragon" "rank_-4.gif" "Golden Double Sided Axe" "rank_0.gif" "Red Wand" "rank_1.gif" "Blue Wand" "rank_2.gif" "Purple Wand" "rank_3.gif" "Golden Double Sided Axe+" "rank_4.gif" "Golden Double Sided Axe" "rank_5.gif" "Silver Double Sided Axe+" "rank_6.gif" "Silver Double Sided Axe" "rank_7.gif" "Double Sided Axe+" "rank_8.gif" "Double Sided Axe" "rank_9.gif" "Double Golden Axe" "rank_10.gif" "Golden Axe" "rank_11.gif" "Double Silver Axe" "rank_12.gif" "Silver Axe" "rank_13.gif" "Double Metal Axe" "rank_14.gif" "Metal Axe" "rank_15.gif" "Double Stone Hammer" "rank_16.gif" "Stone Hammer" "rank_17.gif" "Double Wood Hammer" "rank_18.gif" "Wood Hammer" "rank_19.gif" "Chicken"} $gbinfo(level)]
label .out -font Verdana -text "ID: $gbinfo(id) Rank: $gbinfo(rank) Level: $gbinfo(level) Guild: $gbinfo(guild) GP: $gbinfo(gp)"
pack .out
}
pack .entry
pack .but