Industrial strength whois for multiple queries?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Alexander
Date:  
Subject: Industrial strength whois for multiple queries?
said:
> Hey folks...
>
> My current employer has got a few hundred websites that we want to do a
> whois lookup for? Obviously, we don't wanna end up on anyone's whois
> blacklist by querying too quickly... so does anyone know of a a good
> industrial strength whois lookup? If I had my druthers, we'd find one that
> can return results in consistent XML files...


I wouldn't call this "Industrial strength" but it will basically do what
you want. Save your domains in a file called "domains.txt" and change the
delay to whatever you feel is appropriate (currently set to query every 10
seconds). You'll also need the LWP::RobotUA module if you don't have it
already installed.


#!/usr/bin/perl

use LWP::RobotUA;

open DOMAINS, "domains.txt";
chomp(@domains = <DOMAINS>);
close DOMAINS;
open RESULTS, ">whois_results.txt";

$baseurl = "http://www-whois.internic.net/cgi/whois?";

$browser = LWP::RobotUA->new('Whois Bot','');
$browser->delay(10/60);

foreach $domain (@domains) {
$url = $baseurl . "whois_nic=$domain&type=domain";
$response = $browser->get($url);
$_ = $response->content();
($results) = /<pre>(.*?)<\/pre>/s;
$results =~ s/>>>.*//s;
$results =~ s/.*Whois Server Version.*?Domain Name:/Domain Name:/s;
print RESULTS $results;
}