Subversion Repositories vgwhois

Rev

Rev 11 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/perl

#
#  VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
#  Subprogram: bi TLD whois
#
#  (c) 2015-2019 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
#
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
#

use warnings;
use strict;
use utf8;

use FindBin;
use lib "$FindBin::RealBin/../lib/";
use VGWhoIs::Core;

if (defined $ARGV[0]) {
        $_ = join(' ', @ARGV);
} else {
        # If no parameter is given, await an input from STDIN
        $_ = <>;
        chomp;
}

my $query = $_;

my $host = "http://whois.nic.bi/register/whois.hei"; # TODO: https?

my ($protocol, $hostname) = VGWhoIs::Utils::splitProtocolHost($host);

#print "Querying $hostname with $protocol.\n";

# Get session URL

my $match = 'name="card" value="(.*?)';
my $text = '';
my ($line, $exitcode) = VGWhoIs::Core::getsource($host);
if (!$exitcode) {
        $line =~ s/\n/ /g;
        if ($line =~ $match) {
                ($text) = $line =~ /$match/s;
        }
} else {
        # print STDERR "Query to web server failed.\n";
        print $text;
        exit $exitcode;
}

# Get lookup
($text, $exitcode) = VGWhoIs::Core::doquery($query,'cgi',"$host?card=$text&f_1.qdomain=$query&f_1.type=domain&f_1.q=Search");

if ($exitcode) {
        # print STDERR "Query to web server failed.\n";
}

print $text;

exit $exitcode;