#! /usr/bin/perl
use strict;
use Encode qw(encode decode);
binmode(STDIN,":encoding(utf8)");
binmode(STDOUT,":encoding(utf8)");
binmode(STDERR,":encoding(utf8)");
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTML::TreeBuilder; my @urls;
pushurl(2,"http://sxr.jxnews.com.cn/gy_alllist.php?page=");
pushurl(10,"http://sxr.jxnews.com.cn/sx_list.php?id=22&page=");
pushurl(23,"http://sxr.jxnews.com.cn/sx_list.php?id=23&page=");
pushurl(5,"http://sxr.jxnews.com.cn/sx_list.php?id=24&page=");
pushurl(2,"http://sxr.jxnews.com.cn/sx_list.php?id=25&page=");
pushurl(5,"http://sxr.jxnews.com.cn/sx_list.php?id=26&page=");
push(@urls,"http://sxr.jxnews.com.cn/sx_list.php?id=27");
pushurl(2,"http://sxr.jxnews.com.cn/sx_list.php?id=28&page=");
pushurl(274,"http://sxr.jxnews.com.cn/sx_list.php?id=29&page=");
push(@urls,"http://sxr.jxnews.com.cn/sx_list.php?id=30");
pushurl(6,"http://sxr.jxnews.com.cn/sx_list.php?id=31&page=");
pushurl(177,"http://sxr.jxnews.com.cn/sx_list.php?id=32&page=");
push(@urls,"http://sxr.jxnews.com.cn/sx_list.php?id=33");
print scalar @urls,"\n"; my @urlset;
foreach my $key(@urls){
my $browser=LWP::UserAgent->new();
my $request=HTTP::Request->new("GET"=>$key);
my $response=$browser->request($request);
my $html=$response->content;
my @urls;
while($html=~/href=\"list1\.php\?(.*)\"\starget/g){
my $url1="http://sxr.jxnews.com.cn/list1.php?$1"; #这一步主要是获取id,并与绝对路径拼接,得到的url为最终的请求地址
print $url1,"\n";
push(@urlset,$url1);
}
} open FD ,">>/home/hqh/Desktop/黄启豪/爬虫/江西失信执行/file";
binmode(FD,":encoding(utf8)"); map{getinfo($_)}@urlset;
sub getinfo{
my $url=shift;
my $browser=LWP::UserAgent->new();
my $request=HTTP::Request->new("GET"=>"$url");
my $response=$browser->request($request);
my $html=$response->content;
$html=decode("gb2312", $html);
my $p=HTML::TreeBuilder->new_from_content($html);
my @element1=$p->look_down(_tag=>"table",class=>"imagetable");
foreach(@element1){
my $temp=$_->as_text();
$temp=encode("utf8",$temp);
if($temp=~/被执行人详细信息被执行人:(.*)年龄:(.*)性别:(.*)身份证号码\/组织机构代码:(.*)地址:(.*)案件详细信息立案日期:(.*)执行依据文号:(.*)执行法院:(.*)法律文书确定的义务:(.*)被执行人履行情况:(.*)被执行人失信情形:(.*)/){
my $out=join("||",decode("utf8",$1),
decode("utf8",$2),
decode("utf8",$3),
decode("utf8",$4),
decode("utf8",$5),
decode("utf8",$6),
decode("utf8",$7),
decode("utf8",$8),
decode("utf8",$9),
decode("utf8",$10),
decode("utf8",$11)); #这里用一个正则表达式就可以把表格中所有的数据抽取出来。
print FD $out,"\n";
}
}
} sub pushurl{
my($len,$url)=@_;
for(my $i=0;$i<$len;$i++){
push(@urls,$url.$len);
}
}

  

Perl爬取江西失信执行的更多相关文章

  1. Perl爬取铁路违章旅客信息

    #! /usr/bin/perl use strict; use Encode qw(encode decode); binmode(STDIN,":encoding(utf8)" ...

  2. perl 爬取某理财网站产品信息

    use LWP::UserAgent; use utf8; use DBI; $user="root"; $passwd="xxxxx"; $dbh=" ...

  3. perl 爬取数据<1>

    use LWP::UserAgent; use POSIX; use DBI; $user="root"; $passwd="11111111"; $dbh=& ...

  4. perl 爬取csdn

    <pre name="code" class="python">use LWP::UserAgent; use POSIX; use HTML::T ...

  5. perl 爬取上市公司业绩预告

    <pre name="code" class="python">use LWP::UserAgent; use utf8; use DBI; use ...

  6. perl 爬取同花顺数据

    use LWP::UserAgent; use utf8; use DBI; $user="root"; $passwd='xxx'; $dbh=""; $db ...

  7. 淘宝地址爬取及UI展示

    淘宝地址爬取及UI展示 淘宝国家省市区街道获取 参考 foxiswho 的 taobao-area-php 部分代码,改由c#重构. 引用如下: Autofac MediatR Swagger Han ...

  8. 芝麻HTTP:JavaScript加密逻辑分析与Python模拟执行实现数据爬取

    本节来说明一下 JavaScript 加密逻辑分析并利用 Python 模拟执行 JavaScript 实现数据爬取的过程.在这里以中国空气质量在线监测分析平台为例来进行分析,主要分析其加密逻辑及破解 ...

  9. Scrapy定时执行爬取任务与定时关闭任务

    当我们利用Python scrapy框架写完脚本后,脚本已经可以稳定的进行数据的爬取,但是每次需要手动的执行,太麻烦,如果能自动运行,在自动关闭那就好了,经过小编研究,完全是可以实现的,今天小编介绍2 ...

随机推荐

  1. a new blog from MarsEdit

    终于在网上找到了一款mac 下的blog写作和发布工具了. 先测试一下.

  2. mysql删造成表死锁研究

    现在互联网公司对于代码的管理越来越规范,一般都会有3个环境:开发环境,测试环境,正式环境.在开发环境进行开发,开发完成后将代码提交到测试环境进行测试,测试完毕后上线到正式环境. 今天在正式环境上遇到一 ...

  3. WPF控件 RichTextBox查找定位匹配字符

    private void Search_Click(object sender, RoutedEventArgs e)//查询定位文本 { List<TextRange> textRang ...

  4. Wampserver2.5配置虚拟主机出现403 Forbidden的处理方案

    WampServer是一款由法国人开发的Apache Web服务器.PHP解释器以 及MySQL数据库的整合软件包.免去了开发人员将时间花费在繁琐的配置环境过程,从而腾出更多精力去做开发.在windo ...

  5. BC之jrMz and angles

    jrMz and angles  Accepts: 594  Submissions: 1198  Time Limit: 2000/1000 MS (Java/Others)  Memory Lim ...

  6. OpenGL学习笔记3——缓冲区对象

    在GL中特别提出了缓冲区对象这一概念,是针对提高绘图效率的一个手段.由于GL的架构是基于客户——服务器模型建立的,因此默认所有的绘图数据均是存储在本地客户端,通过GL内核渲染处理以后再将数据发往GPU ...

  7. cvs update后输出的文件标志 和 update常用的几个参数

    (1)update 和 checkout 在执行中,会为每个文件打印一行提示信息,文件的状态通过前面的单个字符指明:       U file        文件按要求从仓库得到更新.用在那些仓库里面 ...

  8. Lucene.net 多条件查询搜索

    最近一直在研究lucene,目的是想让网站实现像搜索引擎那样的搜索,可以快速.准确的帮用户查询出想要的结果.废话不多说,上代码实例: 1.利用BooleanQuery进行多条件搜索(比较灵活)   L ...

  9. oozie调用shell

    <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agree ...

  10. AIDL小结

    AIDL : Android Interface Define Language(接口定义语言) Service中跨进程间通信利器.... 一般都会有Client端和Server端(Server端提供 ...