为什么出现Wide character in print at a14.pl line 41
2016-07-10 22:26
239 查看
[root@wx03 ~]# cat a14.pl use Net::SMTP; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Headers; use HTTP::Response; use Encode; use JSON; use File::Temp qw/tempfile/; use HTTP::Date qw(time2iso str2time time2iso time2isoz); use Data::Dumper; my $CurrTime = time2iso(time()); my $dis_mainpublish='中均资本'; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $now = time(); $ua->agent('Mozilla/5.0'); my $cookie_jar = HTTP::Cookies->new( file => 'lwp_cookies.txt', autosave => 1, ignore_discard => 1 ); $ua->cookie_jar($cookie_jar); my $response = $ua->get("https://www.zjcap.cn/web/noauth?method=%2Fproduct%2Flist&duration=&entryUnit=&productType=1&status=&yield=&productName=&pageNum=1&pageSize=6&_=1468156037154"); if ($response->is_success) { $r = $response->decoded_content; print "\n"; } else { die $response->status_line; }; #my $r=encode_utf8($r); my $hash = decode_json ( $r ); print "11111111111111111111\n"; #print Dumper($hash); print "产品列表\n"; print $hash->{data}->{dataList}->[0]->{name}; [root@wx03 ~]# perl a14.pl 11111111111111111111 产品列表 Wide character in print at a14.pl line 41. 中均-欧洲杯18号(葡萄牙加时/点球夺冠)[root@wx03 ~]# 为什么出现Wide character in print at a14.pl line 41. 呢/ 因为my $hash = decode_json ( $r ); $r 没有转换成utf-8 binary string /**************************************************** [root@wx03 ~]# cat a14.pl use Net::SMTP; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Headers; use HTTP::Response; use Encode; use JSON; use File::Temp qw/tempfile/; use HTTP::Date qw(time2iso str2time time2iso time2isoz); use Data::Dumper; my $CurrTime = time2iso(time()); my $dis_mainpublish='中均资本'; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $now = time(); $ua->agent('Mozilla/5.0'); my $cookie_jar = HTTP::Cookies->new( file => 'lwp_cookies.txt', autosave => 1, ignore_discard => 1 ); $ua->cookie_jar($cookie_jar); my $response = $ua->get("https://www.zjcap.cn/web/noauth?method=%2Fproduct%2Flist&duration=&entryUnit=&productType=1&status=&yield=&productName=&pageNum=1&pageSize=6&_=1468156037154"); if ($response->is_success) { $r = $response->decoded_content; print "\n"; } else { die $response->status_line; }; my $r=encode_utf8($r); my $hash = decode_json ( $r ); print "11111111111111111111\n"; #print Dumper($hash); print "产品列表\n"; print $hash->{data}->{dataList}->[0]->{name}; [root@wx03 ~]# perl a14.pl 11111111111111111111 产品列表 中均-欧洲杯18号(葡萄牙加时/点球夺冠)[root@wx03 ~]#
相关文章推荐
- Xcode7网络请求报错App Transport Security has blocked a cleartext HTTP
- 为什么出现Wide character in print at a14.pl line 41
- 为什么出现Wide character in print at a14.pl line 41
- uva 1635 分解质因数+杨辉三角(二项式)+组合数递推
- js返回匿名函数的疑惑
- 5天玩转C#并行和多线程编程 —— 第二天 并行集合和PLinq
- java-框架-spring概述
- 嵌入式系统开发必读经典书目
- 暑假已开始,读书也开始
- Spring AOP切面实现:参数传递
- python学习——函数返回
- C#高级编程阅读笔记-1
- java线程extends Thread实现(同步代码块)
- L2-004. 这是二叉搜索树吗?
- 在宇宙间不易被风吹散 —— 金星
- 局部内部类能访问非final类型局部变量?
- 最简洁的中断现场保护
- 嵌入式开发为什么选择C语言?
- 巩固基础篇:八皇后问题:经典回溯法
- jvm垃圾收集器配置-1