我需要使用perl查找電子郵件地址和名稱(管理員,註冊員,技術人員的姓名)。需要解析perl中的whois輸出
我檢查過whois輸出有不同的輸出格式。 我試過Net :: ParseWhois和Net :: WhoisNG,但我沒有得到不同域名的電子郵件地址或名稱。
例如像:whois google.com
有什麼辦法,我可以有使用任何Perl模塊,任何域上述資料(電子郵件,姓名等)或如何可以解析爲Perl中的任何域whois的輸出。
我需要使用perl查找電子郵件地址和名稱(管理員,註冊員,技術人員的姓名)。需要解析perl中的whois輸出
我檢查過whois輸出有不同的輸出格式。 我試過Net :: ParseWhois和Net :: WhoisNG,但我沒有得到不同域名的電子郵件地址或名稱。
例如像:whois google.com
有什麼辦法,我可以有使用任何Perl模塊,任何域上述資料(電子郵件,姓名等)或如何可以解析爲Perl中的任何域whois的輸出。
快速複製/粘貼直接從生產概要如下:
use strict;
use warnings;
use Net::WhoisNG;
my $w=new Net::WhoisNG('google.com');
if(!$w->lookUp()){
print "Domain not Found\n";
exit;
}
# If lookup is successful, record is parsed and ready for use
foreach my $type (qw(admin tech registrant bill)) {
my $contact=$w->getPerson($type);
if ($contact) {
print "$type\n";
my $email = $contact->getEmail();
if ($email and $email =~ /\S/) {
print "$email\n";
} else {
my $unparsed = join(' ', @{$contact->getCredentials()});
# Use an regexp to extract e-mail from freeform text here, you can even pick ready one somewhere here on SO
print "$unparsed\n";
}
print "----\n\n";
}
}
結果:
admin
[email protected] +1.6506234000 Fax: +1.6506188571
----
tech
[email protected] +1.6503300100 Fax: +1.6506181499
我會離開提取自由文本電子郵件給你的鍛鍊。
使用Net::Whois::Parser
,它將解析現有的whois
文本或致電Net::Whois::Raw
爲您獲取信息。
但請注意,whois
信息可能不會公開於所有註冊的域:google.com
就是一個例子。
此代碼演示的想法
use strict;
use warnings;
use Net::Whois::Parser;
$Net::Whois::Parser::GET_ALL_VALUES = 1;
my $whois = parse_whois(domain => 'my.sample.url.com');
my @keys = keys %$whois;
for my $category (qw/ admin registrant tech/) {
print "$category:\n";
printf " $_ => $whois->{$_}\n" for grep /^${category}_/, @keys;
print "\n";
}
但新的whois命令行版本確實提供了有關Google的信息。 – kailash19 2012-08-21 05:27:44
根據定義,「whois」輸出是公開的。有些註冊管理機構會限制其內容,例如刪除個人身份信息,但至少對於通用頂級域名(gTLD),您現在可以獲得絕對的一切(當然,除非是隱私代理服務)。但是,您可能會遇到瘦登錄的特定情況,因此您需要兩個whois請求才能獲取所有數據(目前仍爲.COM/.NET,但在2018/2019將會更改)。 – 2018-01-03 23:15:12
你也可以看看'網:: DRI'(我是它的作者)。請注意,無論您使用哪種庫,您的「來自任何域」的要求都很難達到,因爲幾乎每個whois服務器都有不同的輸出,因此需要在庫中花費大量精力來滿足所有情況。 – 2018-01-03 23:16:26