Usage : ./ipsearch 123.456.789.0
#!/usr/bin/perl -w
use warnings;
use URI;
use LWP;
use Encode;
my $ip =$ARGV[0];
chomp($ip);
my $url=URI->new('');
$url->query_form('ip' => $ip);
my $browser = LWP::UserAgent->new;
my $response = $browser->get($url);
$response -> is_success ;
$value = $response -> decoded_content;
#中文解码
#$out = encode("gb2312",$value);
$out = encode("utf8",$value);
#M模式匹配
$str = $out;
$str =~ m/本站主数据\s*(.*?)<\/li>/;
print "$ip $1 \n";
###################################################################
#!/usr/bin/perl -w
use warnings;
use URI;
use LWP;
use Encode;
#用法 ip138search.pl iplist.txt
#以iplist.txt为参数,传入给变量$filename
my $filename=$ARGV[0];
open(FILE,$filename) || die "faile";
my $line;
while($line=){
chomp($line);
my $url=URI->new('');
$url->query_form('ip' => $line);
my $browser = LWP::UserAgent->new;
my $response = $browser->get($url);
if($response -> is_success) {
$value = $response -> decoded_content;
#中文解码
$out = encode("gb2312",$value);
}
else {
die $response -> status_line;
}
#M模式匹配
$str = $out;
$str =~ m/本站主数据:\s*(.*?)<\/li>/;
print "$line $1 \n";
}
close(FILE);
阅读(2398) | 评论(2) | 转发(0) |