[root@node01 ~]#
[root@node01 ~]# cat t2.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;
open DATAFH ,">mq.html";
if ($response->is_success) {
print DATAFH $response->decoded_content;
}
else {
die $response->status_line;
};
close DATAFH;
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)){
print $b.'->'.$_."
";
}
};
close DATAFH3
[root@node01 ~]# perl t2.pl
aaaa->1
TEST->1
aa.cc->0
czcb2017->21
tlcbqueue->0