用于查询手机号码的归属地,代码如下:
#!/perl/bin/perl.exe
## edit by www.jb200.com
#author:make by skylway
#useage:perl 138check.pl $number
#$number为电话号码
##
use strict;
use warnings;
use URI;
use Web::Scraper;
use Encode qw(encode decode);
my $file="C:/Users/Administrator/Desktop/mytest/web.log";
open(LOG ,">$file")||die "ERROR:cann't open $!";
my $number=$ARGV[0];
my $url = "http://www.ip138.com:8080/search.asp?action=mobile&mobile=$number";
my $proce = scraper {
process '.tdc1', "news[]" => "TEXT";
process '.tdc >td', "texts[]" => "TEXT"; };
my $res = $proce->scrape( URI->new($url) );
foreach my $result (@{$res->{news}}) {
$result=encode("gbk",$result);
$result=~s/?//g;
print LOG "$resultn";
}
my @array;
foreach my $result (@{$res->{texts}}) {
$result=encode("gbk",$result);
$result=~s/?//g;
push @array,$result;
print LOG "$resultn";
}
print "$array[5]n";