HTTP头的Perl程序.Below是HTTP heade的代码,输出文件是文本,但我需要一个逗号分隔的文件。
use strict;
use LWP::simple;
use LWP::UserAgent;
use HTTP::Request;
my $URL = 'https://www.gmail.com/';
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 });
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $ua->request($request);
print "URL:$URL\nHeaders:\n";
print $response->headers_as_string;
open (FILE, ">output.txt");
print FILE "URL:$URL\nHeaders:\n";
print FILE $response->headers_as_string;
close(FILE);