zoukankan      html  css  js  c++  java
  • perl 全文搜索tr/td标签内容

    [root@node01 ~]# cat t3.pl
    use  LWP::UserAgent;   
    no warnings;
    use LWP;  
    use Encode;  
    use LWP::Simple;  
    use LWP::UserAgent;  
    use HTTP::Cookies;  
    use HTTP::Headers;  
    use HTTP::Response;  
    use Encode;  
    use URI::Escape;  
    use URI::URL;  
    use JSON;  
    use  LWP::UserAgent;   
    my $ua = LWP::UserAgent->new;  
    $ua->timeout(10);  
    $ua->env_proxy;  
    $ua->agent("Mozilla/8.0");  
    my $host = 'http://admin:admin@192.168.137.3:8161/admin/queues.jsp';  
    my $response = $ua->get($host);  
       $ua->default_headers;  
       
      use HTML::TreeBuilder::XPath;  
      $tree= HTML::TreeBuilder::XPath->new;  
      $tree->parse_file( "mq.html");  
      my @queue=  $tree->findvalues('//tr/td');  
      open DATAFH2 ,">mq.txt";
      foreach $a (@queue){
      $a=~s/s+//g;
      print DATAFH2 $a."
    ";
        
        
    };
    close DATAFH2;
    open (DATAFH3 ,'<',"mq.txt");
    my @queue=('aa.cc','aaaa','czcb2017','TEST','tlcbqueue');
    @arr=();
    while (<DATAFH3>){
       chomp($_);
       if($_ ~~ @queue ){  
          my $line=$.;
          push (@arr,$line);
    }  
    };
    close DATAFH3;
    $num=0;
    open (DATAFH3 ,'<',"mq.txt");
    while (<DATAFH3>){
        chomp;
        $num++;
        if ($num ~~ @arr){
            $a=$num;
            $b=$_;
         };
        if ($a !=0 and ($. == $a + 1)){
             if ($_ >0){
             print $b.'->'.$_."
    ";
             };
            }
          };
    close DATAFH3

  • 相关阅读:
    Run Shell Commands in Python
    Install Fabric 1.8.3 Manually on Ubuntu 12.04
    Setup a Simple HTTP Proxy Server
    去掉文件中的^M
    Build Web Server with Apache and Passenger
    Delete Trailing Spaces with Vim
    Specify Default JDK on Ubuntu
    总结
    问题
    HTTPS 和 HTTP
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349366.html
Copyright © 2011-2022 走看看