Perl爬取江西失信执行
- #! /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爬取江西失信执行的更多相关文章
- Perl爬取铁路违章旅客信息
#! /usr/bin/perl use strict; use Encode qw(encode decode); binmode(STDIN,":encoding(utf8)" ...
- perl 爬取某理财网站产品信息
use LWP::UserAgent; use utf8; use DBI; $user="root"; $passwd="xxxxx"; $dbh=" ...
- perl 爬取数据<1>
use LWP::UserAgent; use POSIX; use DBI; $user="root"; $passwd="11111111"; $dbh=& ...
- perl 爬取csdn
<pre name="code" class="python">use LWP::UserAgent; use POSIX; use HTML::T ...
- perl 爬取上市公司业绩预告
<pre name="code" class="python">use LWP::UserAgent; use utf8; use DBI; use ...
- perl 爬取同花顺数据
use LWP::UserAgent; use utf8; use DBI; $user="root"; $passwd='xxx'; $dbh=""; $db ...
- 淘宝地址爬取及UI展示
淘宝地址爬取及UI展示 淘宝国家省市区街道获取 参考 foxiswho 的 taobao-area-php 部分代码,改由c#重构. 引用如下: Autofac MediatR Swagger Han ...
- 芝麻HTTP:JavaScript加密逻辑分析与Python模拟执行实现数据爬取
本节来说明一下 JavaScript 加密逻辑分析并利用 Python 模拟执行 JavaScript 实现数据爬取的过程.在这里以中国空气质量在线监测分析平台为例来进行分析,主要分析其加密逻辑及破解 ...
- Scrapy定时执行爬取任务与定时关闭任务
当我们利用Python scrapy框架写完脚本后,脚本已经可以稳定的进行数据的爬取,但是每次需要手动的执行,太麻烦,如果能自动运行,在自动关闭那就好了,经过小编研究,完全是可以实现的,今天小编介绍2 ...
随机推荐
- Discrete.Differential.Geometry-An.Applied.Introduction(sig2008)笔记
-------------------------------------------------------------- Chapter 1: Introduction to Discrete D ...
- 手机平板等移动端适配跳转URL的js代码
<script type="text/javascript"> if(/AppleWebKit.*mobile/i.test(navigator.userAgent) ...
- OAF_开发系列29_实现OAF中批次处理迭代器RowSet/RowSetIterator(案例)
20150814 Created By BaoXinjian
- 移动应用开发测试工具Bugtags集成和使用教程
前段时间,有很多APP突然走红,最终却都是樱花一现.作为一个创业团队,突然爆红是非常难得的机会.然并卵,由于没有经过充分的测试,再加上用户的激增,APP闪退.服务器数据异常等问题就被暴露出来,用户的流 ...
- php 二维数组排序,多维数组排序
对2维数组或者多维数组排序是常见的问题,在php中我们有个专门的多维数组排序函数,下面简单介绍下: array_multisort(array1,sorting order, sorting type ...
- C# char 和string之间转换
har数组要转换成string可没想象的那么容易.需要使用到System.Text.StringBuilder!实例如下: char[] temp={a,b,c};System.Text.String ...
- Crypto++ RSA从字符串读取公私匙
string and StringSource (load): string spki = ...; StringSource ss(spki, true /*pumpAll*/); RSA::Pub ...
- 如何去除My97 DatePicker控件上右键弹出官网的链接
http://my97.net/dp/My97DatePicker/calendar.js?最后结尾处: 这个就是官网链接地址了. 然后查找 net,nte,ent,etn,ten,tne最终找到了“ ...
- SQL Server 2008数据库日志收缩
GO ALTER DATABASE MCS SET RECOVERY SIMPLE--设置简单恢复模式 GO DBCC SHRINKFILE (MCS_Log, 1) GO ALTER DATABAS ...
- Mongodb集群搭建过程及常见错误
Replica Sets MongoDB 支持在多个机器中通过异步复制达到故障转移和实现冗余.多机器中同一时刻只 有一台是用于写操作.正是由于这个情况,为 MongoDB 提供了数据一致性的保障.担当 ...