zoukankan      html  css  js  c++  java
  • perl 获取铜板街页码

    node2:/root/pachong/tongbanjie#cat test.pl 
    use LWP::UserAgent;  
    use POSIX;  
    use HTML::TreeBuilder::XPath;   
    use Encode;   
    use HTML::TreeBuilder;    
    use Data::Dumper;
    use HTML::TreeBuilder::XPath;  
    use DBI;  
    use Encode;
      my  $user="root";  
      my  $passwd="1234567";  
      $dbh = DBI->connect("dbi:mysql:database=licai;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;  
      $dbh->do("SET NAMES utf8"); 
       my $ua = LWP::UserAgent->new;  
       $ua->timeout(10);  
       $ua->env_proxy;  
       $ua->agent("Mozilla/8.0");  
           my $tree= HTML::TreeBuilder::XPath->new;  
           $tree->parse_file("test.html");
           my @pageString = $tree->findvalues('/html/body//div[@class="page-control"]/a');  
           print "@pageString is @pageString
    ";
    	   
    	   
    node2:/root/pachong/tongbanjie#cat test.html 
     <div id="pager_COM0_20" class="pager">
        <div class="page-control">
                   <a href="javascript:void(0)" class="page-button page-cur-button">1</a>
                   <a href="javascript:void(0);" data-curPage="2" data-totalPageCount="1091"  class="page-button">2</a>
                   <a href="javascript:void(0);" data-curPage="3" data-totalPageCount="1091"  class="page-button">3</a>
                                                ...
                   <a href="javascript:void(0)" class="page-button" data-totalPageCount="1091" data-curPage="1091">1091</a>
                    <span class="page-next"><a href="javascript:void(0)"data-totalPageCount="1091" data-curPage="2">下一页</a></span>
                      </div>
    				  
    				  
    node2:/root/pachong/tongbanjie#perl test.pl 
    @pageString is 1 2 3 1091
    

  • 相关阅读:
    【Android】开发优化之——调优工具:TrackView,Method Profiling
    MapReduce:具体解释Shuffle过程
    Kafka编程实例
    常用的语句
    CDN
    iOS中的固定 高度
    iPhone手机屏幕的尺寸180330更新
    UITextField
    iOS基本网络请求
    Xcode界面简介
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349798.html
Copyright © 2011-2022 走看看