ultranerds has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have a "links directory", and I'm trying to update the records with as much "proper" data as possible. I've tried using Net::Whois, but that doesn't seem to work. Now, what I need - is a variable or something returned like:

$ref->{administrator}->{phone} .. or something like that.

I've got it working with some domain types (but cos it changes so much between WHOIS records, this doesn't work on a ton of domains - so at the moment, is pretty useless :()

The code I have at the moment is:

my $dominfo = `whois $_`; #whois('perl.com'); my ($name,$email,$phone); # print qq|WHOIS: <pre>$dominfo</pre>|; my @split = split /\n/, $dominfo; foreach (@split) { s/^(\t+|\s+)//sig; s/\s+/ /sig; if (($_ =~ /^Name:(.*)/ || $_ =~ /^Registrant Name:(.*)/) +&& !$name) { # print "NAME IS: $1 \n"; $name = $1; $name =~ s/^\s+//; next; } if (($_ =~ /^Email Address:(.*)/ || $_ =~ /^Registrant Ema +il:(.*)/) && !$email) { # print "NAME IS: $1 \n"; $email = lc($1); $email =~ s/^\s+//; next; } if (($_ =~ /^Phone Number:(.*)/ || $_ =~ /^Registrant Phon +e:(.*)/) && !$phone) { # print "PHONE IS: $1 \n"; $phone = $1; $phone =~ s/^\s+//; next; } }


If anyone has any suggestions, I'm all ears :)

TIA!

Andy

Replies are listed 'Best First'.
Re: Getting whois data.
by eye (Chaplain) on Dec 17, 2008 at 09:24 UTC
    Net::Whois seems to have stalled in 1999. Net::ParseWhois is a replacement that appears active, but does not cover everything (it claims to work for more than 90% of the GTLD registrations).
      Hi eye,

      Thanks - I tried that module, with the basic examples (the test.pl script that comes with the download).

      Then, invoked with:

      perl test.pl gmail.com

      ..and got:

      etrust@factory admin $ perl test.pl gmail.com domain found, registrar unknown. raw data follows ---------------------------------------------------------------------- +- MarkMonitor, the Global Leader in Enterprise Brand Protection Domain Management Online Trademark Protection Online Channel Protection AntiPhishing Solutions ---------------------------------------------------------------------- +- The Data in MarkMonitor.com's WHOIS database is provided by MarkMonito +r.com for information purposes, and to assist persons in obtaining informati +on about or related to a domain name registration record. MarkMonitor.co +m does not guarantee its accuracy. By submitting a WHOIS query, you agr +ee that you will use this Data only for lawful purposes and that, under n +o circumstances will you use this Data to: (1) allow, enable, or otherwi +se support the transmission of mass unsolicited, commercial advertising o +r solicitations via e-mail (spam); or (2) enable high volume, automated +, electronic processes that apply to MarkMonitor.com (or its systems). MarkMonitor.com reserves the right to modify these terms at any time. By submitting this query, you agree to abide by this policy. Registrant: DNS Admin Google Inc. Please contact gmail-abuse@google.com 1600 Amphitheatre Parkway Mountain View CA 94043 US gmail-abuse@google.com +1.6502530000 Fax: +1.6506188571 Domain Name: gmail.com Registrar Name: Markmonitor.com Registrar Whois: whois.markmonitor.com Registrar Homepage: http://www.markmonitor.com Administrative Contact: DNS Admin Google Inc. 1600 Amphitheatre Parkway Mountain View CA 94043 US dns-admin@google.com +1.6502530000 Fax: +1.6506188571 Technical Contact, Zone Contact: DNS Admin Google Inc. 1600 Amphitheatre Parkway Mountain View CA 94043 US dns-admin@google.com +1.6502530000 Fax: +1.6506188571 Created on..............: 1995-08-13. Expires on..............: 2014-08-11. Record last updated on..: 2008-06-11. Domain servers in listed order: ns3.google.com ns4.google.com ns2.google.com ns1.google.com ---------------------------------------------------------------------- +- MarkMonitor, the Global Leader in Enterprise Brand Protection Domain Management Online Trademark Protection Online Channel Protection AntiPhishing Solutions ---------------------------------------------------------------------- +- -- etrust@factory admin $


      Also tried it with a load of other domains, and that doesn't work either :|

      Any other suggestions?

      TIA for your help :)

      Andy
        BTW, it seems ok on .org formats! (same as with my regex stuff above) - but .com, .net, .co.uk and tons of other formats don't work :|
Re: Getting whois data.
by jwkrahn (Abbot) on Dec 17, 2008 at 10:22 UTC
    my $dominfo = `whois $_`; #whois('perl.com'); my @split = split /\n/, $dominfo;

    That should be just:

    chomp( my @split = `whois $_` ); #whois('perl.com');
    s/^(\t+|\s+)//sig;

    That should be just:

    s/^\s+//;
    s/\s+/ /sig;

    That should be just:

    s/\s+/ /g;