Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取JSON格式的perl API调用时出现的问题_Java_Perl_Subdomain - Fatal编程技术网

Java 获取JSON格式的perl API调用时出现的问题

Java 获取JSON格式的perl API调用时出现的问题,java,perl,subdomain,Java,Perl,Subdomain,您好,我在接受JSON中的perl API调用时遇到问题,我想从该链接获取所有子域 #!/usr/bin/perl use strict; use warnings; use HTTP::Request; use LWP::UserAgent; use HTTP::Response; use HTTP::Request::Common qw(POST); use HTTP::Request::Common qw(GET); use Data::Dumper; use LWP::Simple;

您好,我在接受JSON中的perl API调用时遇到问题,我想从该链接获取所有子域

#!/usr/bin/perl

use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use HTTP::Response;
use HTTP::Request::Common qw(POST);
use HTTP::Request::Common qw(GET);
use Data::Dumper;
use LWP::Simple;
use JSON qw( decode_json encode_json );

my $ua = LWP::UserAgent->new;
$ua = LWP::UserAgent->new(keep_alive => 1);
$ua->agent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31");

my $url = "https://www.threatcrowd.org/searchApi/v2/domain/report/?domain=fb.com";

my $request = $ua->get($url);
my $response = $request->content;

my $decoded = decode_json($response);

print $decoded->{'subdomains'};
如果运行这个脚本,得到这个

C:\Users\USER\Desktop>1.pl
ARRAY(0x625c868

如果它确实是一个简单的数组引用(您可以使用进行检查),则需要迭代列表并打印每个元素/项:

for my $element (@{ $decoded->{'subdomains'} }){
    print "$element\n";
}
@{}
语法是一个解引用运算符。它取消引用大括号内变量中的数组引用


有关更多信息,请参阅文档中的部分。

如果它确实是一个简单的数组引用(您可以使用进行检查),则需要遍历列表并打印每个元素/项:

for my $element (@{ $decoded->{'subdomains'} }){
    print "$element\n";
}
@{}
语法是一个解引用运算符。它取消引用大括号内变量中的数组引用

有关更多信息,请参阅文档中的部分