Net::W...Parser(3pm)

πŸ“¦
version 0.08 Β· 2 versions
  • 0.08 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.08 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::W...Parser β€” your fave whois whisperer πŸ’–

okay so bestie, welcome to Net::W...Parser(3pm), one of the pages that lives under User Contributed Perl Documentation 🌸. It's the manual for Net::Whois::Parser and honestly? she eats. let's get into it πŸ’…


✨ NAME ✨

Net::Whois::Parser β€” a module for parsing whois information πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

okay so first things first, you pull her in:

use Net::Whois::Parser;

my $info = parse_whois( domain => $domain );
my $info = parse_whois( raw => $whois_raw_text, domain => $domain  );
my $info = parse_whois( raw => $whois_raw_text, server => $whois_server  );

$info = {
    nameservers => [
        { domain => 'ns.example.com', ip => '123.123.123.123' },
        { domain => 'ns.example.com' },
    ],
    emails => [ 'admin@example.com' ],
    domain => 'example.com',
    somefield1 => 'value',
    somefield2 => [ 'value', 'value2' ],
    ...
};

like, that's the whole vibe β€” you feed her a domain or some raw text, she hands you back a lil hash full of goodies. nameservers? emails? domain? whatever the server decided to spill? all in there 😌✨

but WAIT, there's more, because you can also write your own parsers, and that's the part that's genuinely iconic:

# Your own parsers

sub my_parser {
    my ( $text ) = @_;
    return {
        nameservers => [
            { domain => 'ns.example.com', ip => '123.123.123.123' },
            { domain => 'ns.example.com' },
        ],
        emails => [ 'admin@example.com' ],
        somefield => 'value',
        somefield2 => [ 'value', 'value2' ],
    };
}

$Net::Whois::Parser::PARSERS{'whois.example.com'} = \&my_parser;
$Net::Whois::Parser::PARSERS{'DEFAULT'}           = \&my_default_parser;

yes bestie, you just drop your sub into %Net::Whois::Parser::PARSERS keyed by whois server, and if nobody matches, 'DEFAULT' catches it. main character energy fr fr πŸ‘‘

and then there's the lil extras, the seasoning, if you will πŸ“:

# If you want to get all values of fields from all whois answers
$Net::Whois::Parser::GET_ALL_VALUES = 1;
    # example
    # Net::Whois::Raw returns 2 answers
    $raw = [ { text => 'key: value1' }, { text => 'key: value2'}];
    $data = parse_whois(raw => $raw);
    # If flag is off parser returns
    # { key => 'value2' };
    # If flag is on parser returns
    # { key => [ 'value1', 'value2' ] };

# If you want to convert some field name to another:
$Net::Whois::Parser::FIELD_NAME_CONV{'Domain name'} = 'domain';

# If you want to format some fields.
# I think it is very useful for dates.
$Net::Whois::Parser::HOOKS{'expiration_date'} = [ \&format_date ];

so $GET_ALL_VALUES decides whether repeated fields collapse down to the last one or pile up into a whole array, %FIELD_NAME_CONV renames fields for you, and %HOOKS lets you run your own formatting on a field β€” and yeah, dates are literally the perfect use case for that, no cap πŸ—“οΈπŸ’–


🌈 DESCRIPTION 🌈

Net::Whois::Parser module provides Whois data parsing. You can add your own parsers for any whois server. πŸ¦‹βœ¨

that's it, that's the pitch β€” she parses whois data, and she's endlessly extendable, so every server can have its own lil handler. obsessed πŸ’œ


πŸ‘‘ FUNCTIONS πŸ‘‘

parse_whois(%args)

Returns hash of whois data. Arguments: πŸ’«

  • 'domain' β€” domain
  • 'raw' β€” raw whois text
  • 'server' β€” whois server
  • 'which_whois' β€” option for Net::Whois::Raw::whois. Default value is QRY_ALL

πŸ¦‹ CHANGES πŸ¦‹

See file "Changes" in the distribution πŸ“„βœ¨


🫢 AUTHOR 🫢

Ivan Sokolov, "<ivsokolov@cpan.org>" β€” ty for your service king πŸ’–


Copyright 2009 Ivan Sokolov

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸŽ€


and that's the whole page bestie, we're done!! this was perl v5.34.0, dated 2022-06-16, and the page you just read is Net::W...Parser(3pm). go forth and parse some whois, you're gonna slay πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ’…πŸ‘‘

πŸ“¦ where this page comes from