您的位置:首页 > 其它

perl 自定义请求头

2015-12-10 18:02 471 查看
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
@header = (
'accept'=> "application/json",
'content-type'=> "application/json",
'apix-key'=> "e7b00871640c49567a37566ccd5c27e9",
'User-Agent' => "Mozilla/8.0"
);

$start = $ARGV[0];
$end = $ARGV[1];
$date = $ARGV[2];
$host="http://a.apix.cn/apixlife/ticket/rest?from=$start&to=$end&date=$date";
$request = HTTP::Request->new(GET=>"$host");
$request->header(@header);

$response = $ua->request($request);
$content= $response->decoded_content;
$content =~ s/\\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg;
print "\$content is $content\n";
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: