#!/usr/bin/perl -w # tldlookup.pl -- looks up the country to which a TLD # corresponds. # seems to me there ought to be a *nix utility # to do this, but I couldn't find one easily. use LWP::Simple; use strict; die "usage: tldlookup.pl [tlds] -- where the tlds do not contain perio +ds.\n" unless @ARGV; my %names; # note this URL *could* conceivably change, so keep that in mind # future expansion : get it to recognize OTHER kinds of TLDs, # not just the country codes. That's version .02, I guess my $tld_url = "http://www.iana.org/cctld/cctld-whois.htm"; my $data = get $tld_url; # Oh, my, this *is* flying by the seat of the pants, isn't it? while (my $tld = shift @ARGV) { ( $names{$tld} ) = ($data =~ /(?:\.$tld)[^A-Z]+([^<]+)/); $names{$tld} = "not found" if (!defined($names{$tld}) || length ($tld) < 2); ; } foreach (keys %names) { print ".$_ => $names{$_}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TLD lookup
by mdillon (Priest) on Nov 23, 2000 at 08:17 UTC | |
|
Re: TLD lookup
by dws (Chancellor) on Nov 23, 2000 at 07:18 UTC | |
by mdillon (Priest) on Nov 23, 2000 at 08:01 UTC | |
by arturo (Vicar) on Nov 27, 2000 at 00:24 UTC |