Snarfing up the goods
--#--
We now have a list of 50 GM domain names (and if I figure out how to
get more than 50, you'll see it here first). We can use this list to
construct 50 more queries against the NSI WHOIS server.
First, let's just see if we can get responses back from the server. We've
already defined the CGI process we'll go against (it's in the Perl variable
$process). All we need to do is send it a new request using the
Perl back reference $1 from the last line of code.
Delete this line and replace it with the following lines:
$request = POST $process, [$name => $1];
$response = $ua->request($request);
if ($response->is_success) {
print "$response->content\n";
}
Voila! There are our 50 InterNIC listings, HTML and all. Cleaning out
the HTML is a snap. Take a close look at the HTML. Each record is enclosed
in a <pre></pre> tag pair. It's a simple matter of just taking
what's in between. First, though, copy the record into another Perl variable
so we can strip it:
$info = $response->content;
$info =~ s/(.*)<\/pre>/$1/is;
The ".*" simply matches anything between the formatting tags.
The i on the end of the pattern matcher makes it case-insensitive, and
the s makes it match line breaks as if they were spaces.
Finally, let's print a little separator between the records:
print "$info\n----------------------\n";
That's about it, gang. Wait ...
You're behind a proxy firewall? That does present a problem.
But thanks to the powers of the Perl community, and the mighty LWP
library, it's not a big one. Here's what to do.