这是一个使用ip138归属地查询的perl脚本
 
先到 http://search.cpan.org/  搜索下载 LWP::Simple 模块
 
#!/usr/bin/perl
use strict;
use utf8;
binmode(STDOUT, ':encoding(utf8)');
use LWP::Simple;
my $ip = ;
chomp ($ip);
my $url = " http://ip138.com/ips.asp?ip=$ip&action=2";
my $content = get $url;
 die "Couldn't get $url" unless defined $content;
my @diqus = ($content =~ m#
  • (.*)
  • (.*)
  • (.*)
  • #ig);
    print "@diqus\n";