#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use XML::Twig;
use HTTP::Request;
my @joblist = ('Testing','Integrity','TEST','Team_test','test','TEST_1','Update_Outlook');
my @score;
foreach my $job_name (@joblist) {
my $url_a = 'http://myhost:8080/job/$job_name/api/xml';
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get($url_a);
if ($response->is_success) {
my $content = $response->decoded_content; # or whatever
XML::Twig->new( twig_roots => { 'healthReport/score' => sub { push @score, $_->text; } }) ->parseurl($url_a);
foreach my $var (@score) {
print "$var \n";
}
}
else {
die $response->status_line;
}
}
在上面的 perl 代码中,我将 $job_name 调用到另一个变量 $url_a 中。但我收到以下错误。
404 Not Found at health.pl line 25.
有人可以帮我解决这个问题。谢谢。