perl之查询电话号码区域信息
来源:互联网 发布:sql 2000 win7 64位 编辑:程序博客网 时间:2024/04/28 10:34
利用perl脚本查询手机号码的地区信息:
use LWP;
use HTML::TreeBuilder;
my $phone = $ARGV[0];
if(!defined($phone))
{
print "号码不能为空,请输入电话号码.";
exit(-1);
}
my $geo,$type,$zone,$code;
my $found_geo = 0,$found_type = 0,$found_zone = 0,$found_code = 0;
my $ua = LWP::UserAgent->new();
my $reponse = $ua->get("http://www.ip138.com:8080/search.asp?mobile=$phone&action=mobile");
my $content = $reponse->content;
#print $content;
my $tree = HTML::TreeBuilder->new;
$content =~ s/ //g;
$tree->parse($content);
$tree->eof();
#$tree->dump();
foreach my $row ( $tree->find_by_tag_name("tr") ) {
foreach my $cell ( $row->content_list ) {
if($cell->as_text =~ /卡号归属地/)
{
$found_geo = 1;
next;
}
elsif($cell->as_text =~ /卡类型/)
{
$found_type = 1;
next;
}
elsif($cell->as_text =~ /区 号/)
{
$found_zone = 1;
next;
}
elsif($cell->as_text =~ /邮 编/)
{
$found_code = 1;
next;
}
if($found_geo)
{
$geo = $cell->as_text;
$found_geo = 0;
next;
}
if($found_type)
{
$type = $cell->as_text;
$found_type = 0;
next;
}
if($found_zone)
{
$zone = $cell->as_text;
$found_zone = 0;
next;
}
if($found_code)
{
$code = $cell->as_text;
$found_code = 0;
last;
}
}
}
print "手机号码: $phone/n";
print "卡号归属地: $geo/n";
print "卡类型: $type/n";
print "区 号:$zone/n";
print "邮 编:$code/n";
$tree->delete();
- perl之查询电话号码区域信息
- 美国邮编及电话号码区域查询
- android之电话号码查询
- perl tools 查询服务器信息
- CommunityStarterKit之区域信息
- iPhone查询通讯录中的联系人信息(电话号码及邮箱)
- 代码实现之查询代码页的信息(附加:关于系统区域设置的说明)
- windows系统信息,内存状态,区域信息的查询
- 电话号码查询子程序
- 电话号码查询系统
- 电话号码归属查询
- 电话号码归属地查询
- 慕课网电话号码查询研究
- 站点 区域 网址导航 信息类查询请程序员指教
- 查找IP位置 \ c# 通过经纬度 查询地址、区域信息
- 电话号码归属地查询——利用邮编从网络上抓取地址信息(1)
- 电话号码归属地查询——利用邮编从网络上抓取地址信息(2)
- 用PhoneLookup进行电话号码查询
- Eclipse没有Software updates选项的解决办法
- 心情好差
- 心情好差
- [C++]typedef typename什么意思?
- 绘制太阳黑子图
- perl之查询电话号码区域信息
- T(n) & S(n)
- 从名称认识电容在电路中的作用(转载)
- abator安装及详解
- 关于ORACLE UNION ALL 遇到的问题
- 在Android使用RSA 算法加解密
- Android各种Layout用到的一些重要的属性
- 配置VIM
- .NET中的FileUpload控件