NAME
NOLookup::Whois::WhoisLookup - Lookup WHOIS data from Norid.
SYNOPSIS
use Encode;
use NOLookup::Whois::WhoisLookup;
# The $SERVER and $PORT can be set to what you need.
# The defaults are the below, so in this case they don't
# change anything.
my $SERVER = 'whois.norid.no';
my $PORT = 43;
# Example 1: Domain name lookup
# Decode the query when needed, like for IDNs
# or names with national characters.
my $q = decode('UTF-8', 'norid.no');
my ($wh, $do, $ho) = NOLookup::Whois::WhoisLookup->new($q, $SERVER, $PORT);
# $wh is always populated.
# For a domain lookup, the $do and $ho objects should be
# used to access the domain and holder information.
# In all other cases, $wh contains the information.
if ($wh->errno) {
print STDERR "Whois error: ", $wh->errno, "\n";
if ($wh->raw_text) {
print STDERR "Raw text : ", $wh->raw_text, "\n";
}
exit;
}
print $wh->post_address;
print $wh->domain_name;
print $wh->name;
if ($do && $ho) {
# when a domain name or domain handle is looked up,
# $do contains the domain information,
# and $ho contains the holder information
print "Domain name : ", encode('UTF-8', $do->domain_name), "\n";
print "Holder name : ", encode('UTF-8', $ho->name), "\n";
print "Holder address: ", encode('UTF-8', $ho->post_address), "\n";
}
# Example 2: Registrar lookup
$q = 'reg2-norid';
$wh = NOLookup::Whois::WhoisLookup->new($q);
unless ($wh->errno) {
print "Registrar name : ", encode('UTF-8', $wh->registrar_name), "\n";
print "Registrar email: ", $wh->email_address, "\n";
}
DESCRIPTION
This module provides an object oriented API for use with the Norid whois service. It uses the command line based whois interface internally to fetch information from Norid.
The values in the objects are decoded to internal perl data.
This code is stolen from Cpan package Net::Whois::Norid and adapted to suit our needs. Adaption was needed because create date etc. were not collected. We could've considered using the module as it was, but it also dragged in some more modules which seems a bit much for such a simple task.
Also nice to produce some more error codes.
METHODS
- new
-
The constructor. Takes an optional lookup argument. Returns a new object.
- lookup
-
Do a whois lookup in the Norid database and populate the object from the result.
- get
-
Use this to access any data parsed. Note that spaces and '-'s will be converted to underscores (_). For the special "Handle" entries, omitting the _Handle part will return a new NOLookup::Whois::WhoisLookup object.
The method is case insensitive.
- TO_JSON
-
Note: The name of this method is important, must be upper case and name must not be changed!
Provide a TO_JSON method for JSON usage, ref. TO_JSON discussion in https://metacpan.org/pod/JSON
JSON does not handles objects, as the internals are not known, then we need a method to present the object as a hash structure for JSON to use. This method does the conversion from object to a hash ready for JSON encoding.
- AUTOLOAD
-
This module uses the autoload mechanism to provide accessors for any available data through the get mechanism above.
SUPPORT
For now, support questions should be sent to:
<(nospam)info(at)norid.no>
SEE ALSO
https://www.norid.no/en https://teknisk.norid.no/en/integrere-mot-norid/whois
CAVEATS
Some rows in the whois data, like address lines, might appear more than once. In that case they are separated with line space. For objects, an array is returned.
AUTHOR
Trond Haugen, <(nospam)info(at)norid.no>
COPYRIGHT
Copyright (c) 2017 Trond Haugen <(nospam)info(at)norid.no>. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
LICENSE
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.