alias country {
%dns = $$1
%country = $gettok(%dns,-1,46)
%host = $deltok(%dns,-1,46)
sockopen country ftp.ics.uci.edu 80
}
alias -l html {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
return %x
}
on *:sockopen:country: {
sockwrite -n $sockname GET /pub/websoft/wwwstat/country-codes.txt HTTP/1.1
sockwrite -n $sockname Host: ftp.ics.uci.edu $+ $crlf $+ $crlf
}
on *:sockread:country: {
if ($sockerr) {
halt
}
else {
var %sock.country
sockread %sock.country
if (%country isin %sock.country) {
if ($gettok($html(%sock.country),1,32) == %country) {
; $gettok($html(%sock.country),1,32) returns country in 2 letters.
; $gettok($html(%sock.country),2-,32) returns the full country name.
echo -a $gettok($html(%sock.country),1,32) = $gettok($html(%sock.country),2-,32)
}
}
}
}