#! /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. 02shell编程环境的搭建

    02shell编程环境的搭建 [02]Shell编程 02shell编程环境的搭建 在不同的操作系统上搭建shell编程环境 Linux Windows Mac 编辑器的选择 系统环境的搭建 注: 选 ...

  2. 找不到方法:“Boolean System.Runtime.Serialization.DataContractAttribute.get_IsReference()”的解决办法

    找不到方法:“Boolean System.Runtime.Serialization.DataContractAttribute.get_IsReference()”.的解决办法站点发布后部署到了两 ...

  3. 使用git新建分支以及管理分支

    在进行分支相关的操作前, 我们需要保持主分支干净, 所谓的干净就是没有任何改变(所有更改都已经commit 并 push),那么你可以在任何时候从你的主分支创建一个新分支. 为了方便代码管理,我们应该 ...

  4. /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc

    /etc/profile./etc/bashrc.~/.bash_profile.~/.bashrc很容易混淆,他们之间有什么区别?它们的作用到底是什么?/etc/profile: 用来设置系统环境参 ...

  5. php中序列化与反序列化

    解析PHP多种序列化与反序列化的方法 序列化是将变量转换为可保存或传输的字符串的过程:反序列化就是在适当的时候把这个字符串再转化成原来的变量使用.这两个过程结合起来,可以轻松地存储和传输数据,使程序更 ...

  6. boost multi_index

    /** boost 多索引容器的一般使用 这里使用google 的gmock 库来验证对boost 多索引模板的使用,并验证. 这里是手敲的,可能会有一些字符敲错的情况,编译错误的放,修改一下,同时链 ...

  7. PHP中include和require的区别详解

    1.概要 require()语句的性能与include()相类似,都是包括并运行指定文件.不同之处在于:对include()语句来说,在执行文件时每次都要进行读取和评估:而对于require()来说, ...

  8. lucene 内存索引 和文件索引 合并

    IndexWriter.addIndexes(ramDirectory); http://blog.csdn.net/qq_28042463/article/details/51538283 在luc ...

  9. java获取配置文件里面的内容

    InputStream in = ReadProperties.class.getClassLoader() .getResourceAsStream("test.properties&qu ...

  10. virtualbox桥接网络配置--CentOS

    系统安装好后如下图设置virtualbox虚拟机的网络连接方式 然后启动虚拟机 ifconfig发现如下图 vi /etc/sysconfig/network-scripts/ifcfg-eth0 根 ...