• perl 解析JSON


    [root@dr-mysql01 ~]# cat ip.pl 
    use Encode;
    use Encode::CN;
    use JSON; 
    use URI::Escape;
    use LWP::Simple;
    print "hostip is $_
    ";	
    $host = "http://ip.taobao.com/service/getIpInfo.php?ip=$ARGV[0]";
    $content = get($host);
    print "$content
    ";
    $perl_scalar = decode_json($content);
    $var=$perl_scalar->{data}->{ip};
    print $var
    [root@dr-mysql01 ~]# perl ip.pl  202.101.172.35
    hostip is 
    {"code":0,"data":{"country":"u4e2du56fd","country_id":"CN","area":"u534eu4e1c","area_id":"300000","region":"u6d59u6c5fu7701","region_id":"330000","city":"u676du5ddeu5e02","city_id":"330100","county":"","county_id":"-1","isp":"u7535u4fe1","isp_id":"100017","ip":"202.101.172.35"}}
    202.101.172.35[root@dr-mysql01 ~]# 

  • 相关阅读:
    Codeforces 1354C2
    Codeforces 1354C1
    Codeforces 1355C
    Codeforces 1353D
    Codeforces 1352
    Codeforces 1351C
    Codeforces 1344B/1345D
    Codeforces 1342D
    Codeforces 1340B/1341D
    Codeforces 1343D
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351134.html
Copyright © 2020-2023  润新知