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

  

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. PHP面向对象基础part.1

  2. HTML5常用的方法

    1.html禁止手机页面放大缩小 在页面head中加入<meta name="viewport" content="width=device-width, init ...

  3. oracle中找出某个字段中有非数字型的记录

    工作中遇到一个大表记录中有非法非数字字符,不想用正则语法去做, 用一条SQL语句查出来的方法如下: select * from table where translate(col,'*01234567 ...

  4. C#位操作(转)

    在C#中可以对整型运算对象按位进行逻辑运算.按位进行逻辑运算的意义是:依次取被运算对象的每个位,进行逻辑运算,每个位的逻辑运算结果是结果值的每个位.C#支持的位逻辑运算符如表2.9所示. 算符号 意义 ...

  5. Spring自定义缓存管理及配置Ehcache缓存

    spring自带缓存.自建缓存管理器等都可解决项目部分性能问题.结合Ehcache后性能更优,使用也比较简单. 在进行Ehcache学习之前,最好对Spring自带的缓存管理有一个总体的认识. 这篇文 ...

  6. 常用PHP函数类目录

    说明:用来记录我在开发过程中,经常用到的一些常用函数或者常用类. 常用函数 PHP常用函数 (1) 常用类 PHP表单数据校验类

  7. 介绍Unreal Engine 4中的接口(Interface)使用C++和蓝图

    这个教程是从UE4 Wiki上整理而来. 在C++中直接使用Interface大家应该很熟悉.只是简单先定义一个个有虚函数的基类,然后在子类中实现相应的虚函数.像这样的虚函数的基类一般概念上叫接口.那 ...

  8. .gitignore 使用中注意的问题

    在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改 .gitignore 文件的方法.这个文件每一行保存了一个匹配的规则例如: # 此为注释 – 将被 Git 忽略 *.a    ...

  9. Bootstrap框架(基础篇)之按钮,网格,导航栏,下拉菜单

    一,按钮 注意:虽然在Bootstrap框架中使用任何标签元素都可以实现按钮风格,但个人并不建议这样使用,为了避免浏览器兼容性问题,个人强烈建议使用button或a标签来制作按钮. 框架中提供了基础按 ...

  10. Access denied for user 'Administrator'@'localhost' (using password: YES)

    Access denied for user 'Administrator'@'localhost' (using password: YES) 配置文件中明明是用的root <entry ke ...