zoukankan      html  css  js  c++  java
  • perl lwp 响应信息

    [root@dr-mysql01 ~]# cat hcp.pl 
    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
    ";
    
    [root@dr-mysql01 ~]# set -o vi
    [root@dr-mysql01 ~]# ^Crl zabbix.pl  a
    [root@dr-mysql01 ~]# perl hcp.pl BJP TJP 2015-12-11
    $content is <h1>403 Forbidden</h1>
    [root@dr-mysql01 ~]# perl hcp.pl BJP TJP 2015-12-11
    $content is <h1>403 Forbidden</h1>
    [root@dr-mysql01 ~]# perl hcp.pl BJP TJP 2015-12-11
    $content is <h1>403 Forbidden</h1>
    [root@dr-mysql01 ~]# perl hcp.pl BJP TJP 2015-12-11
    Wide character in print at hcp.pl line 20.
    $content is {"status": true, "validateMessagesShowId": "_validatorMessage", "messages": [], "httpstatus": 200, "validateMessages": {}, "data": {"message": "没有符合条件的数据!", "flag": false}}
    [root@dr-mysql01 ~]# vim hcp.pl 
    You have new mail in /var/spool/mail/root
    [root@dr-mysql01 ~]# perl hcp.pl BJP TJP 2015-12-11
    $content is {
        "error": "Key not authorised"
    }

  • 相关阅读:
    HPU--1189 Ou à
    实数向整数的强制转换
    HPU--1166 阶乘问题(一)
    HPU--1163 大数A+B
    阿斯伯格综合征完全指南各章链接
    思维改变生活第10章、有效沟通
    Mathematica(MMA)闪电入门系列 目录与说明
    第二语言习得理论介绍
    第二语言习得实践方法
    复赛注意事项:关于文件读写的格式
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351111.html
Copyright © 2011-2022 走看看