Subversion Repositories vgwhois

Rev

Rev 5 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
#!/usr/bin/perl
2
 
3
#
11 daniel-mar 4
#  VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
5 daniel-mar 5
#  Subprogram: pe TLD whois
2 daniel-mar 6
#
5 daniel-mar 7
#  (c) 2015 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
2 daniel-mar 8
#
5 daniel-mar 9
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
2 daniel-mar 10
#
11
 
12
use warnings;
13
use strict;
14
use utf8;
15
 
16
use FindBin;
4 daniel-mar 17
use lib "$FindBin::RealBin/../lib/";
11 daniel-mar 18
use VGWhoIs::Core;
2 daniel-mar 19
 
20
if (defined $ARGV[0]) {
21
	$_ = join(' ', @ARGV);
22
} else {
23
	# If no parameter is given, await an input from STDIN
24
	$_ = <>;
25
	chomp;
26
}
27
 
28
my $query = $_;
29
 
30
my $host       = "http://www.nic.pe/rpublicac-i.php?txtbuscar=$query&radopcion=D"; # TODO: https?
31
my $additional = "(detpublic-i.php.*?)'";
32
 
11 daniel-mar 33
my ($protocol, $hostname) = VGWhoIs::Utils::splitProtocolHost($host);
2 daniel-mar 34
 
35
#print "Querying $hostname with $protocol.\n";
36
 
11 daniel-mar 37
my ($text, $exitcode) = VGWhoIs::Core::wwwsgrep($host,$additional);
2 daniel-mar 38
if ($exitcode) {
39
	# print STDERR "Query to web server failed.\n";
40
	print $text;
41
	exit $exitcode;
42
}
43
 
44
if ($text ne '') {
45
	print "Match found. Now querying for the domain data.\n\n";
11 daniel-mar 46
	($text, $exitcode) = VGWhoIs::Core::doquery($query,'cgi',"$protocol://$hostname/$text", '');
2 daniel-mar 47
	print $text;
48
} else {
49
	print "No match found. This probably means that this domain does not exist.\n";
50
}
51
 
52
if ($exitcode) {
53
	# print STDERR "Query to web server failed.\n";
54
}
55
 
56
exit $exitcode;