Wide character in print at a2.pl line 返回json 需要encode_utf8
centos6.5:/root/test#cat a2.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 "产品列表\n";
print $hash->{data}->{dataList}->[0]->{name};
print "\n";
centos6.5:/root/test#perl a2.pl 11111111111111111111
产品列表
Wide character in print at a2.pl line 40.
爱晚-融通宝第9期 因为decode_json必须是unicode字符 ,返回的json数据前需要转成unicode my $r=encode_utf8($r); centos6.5:/root/test#cat a2.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 "产品列表\n";
print $hash->{data}->{dataList}->[0]->{name};
print "\n";
centos6.5:/root/test#perl a2.pl 11111111111111111111
产品列表
爱晚-融通宝第9期
Wide character in print at a2.pl line 返回json 需要encode_utf8的更多相关文章
- Wide character in print at a2.pl line 6.
jrhapt01:/home/tomcat/test> cat a2.pl my $str="$ARGV[0]"; use Encode; use URI::Escape; ...
- perl unload utf-8 oracle Wide character in print at unload_oracle.pl line 105.
#!/usr/bin/perl use DBI; use Encode; my $dbName = 'oadb'; my $dbUser = 'vxspace'; my $dbUserPass = ' ...
- Wide character in print at hcp.pl line 21.
jrhmpt01:/root# cat -n hcp.pl 1 use LWP::UserAgent; 2 use Encode; 3 $ua = LWP::UserAgent->new; 4 ...
- 为什么出现Wide character in print at a14.pl line 41
[root@wx03 ~]# cat a14.pl use Net::SMTP; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Headers; u ...
- php 返回json 解析 报Wide character in print
php 返回json: zabbix:/var/www/html/DEVOPS/Home/Lib/Action# vim EquipmentAction.class.php <?php head ...
- Can't locate find.pl in @INC (@INC contains: /etc/perl xxxx) at perlpath.pl line 7.
/********************************************************************** * Can't locate find.pl in @I ...
- error: converting to execution character set: Invalid or incomplete multibyte or wide character
交叉编译.c文件,遇到如下问题 arm-linux-gcc -o show_lines show_lines.c -lfreetype -lm show_lines.c:199:19: error: ...
- SyntaxError: Non-ASCII character 'æ' in file csdn.py on line 7, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
错误信息: SyntaxError: Non-ASCII character , but no encoding declared; see http://python.org/dev/peps/pe ...
- 编译内核错误:Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373
最近在编译一个新的rk sdk的时候,编译内核报错 CHK include/linux/version.h CHK include/generated/utsrelease.h make[1]: 'i ...
随机推荐
- datejs lib
// Get today's date Date.today(); // Add 5 days to today Date.today().add(5).days(); // Get Friday o ...
- FastFrameWork 快速开发框架
前言 FastFrameWork 快速开发框架是一款基于敏捷并行开发思想和Microsoft .Net构件(插件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市场快速变化的 ...
- Ext.Net学习笔记09:Ext.Net Store的用法
使用Handler处理分页 首先来创建一般处理程序,我命名为StoreHandler.ashx,然后它的处理过程代码如下: public void ProcessRequest(HttpContext ...
- 最新的 cocoapods 安装与使用(2016.11)
cocoapods简介: cocoapods 是iOS的类库管理工具,可以让开发者很方便集成各种第三方库,而不用去网站上一个个下载,再一个个文件夹的拖进项目中,还得添加相关的系统依赖库.只需要安装好c ...
- IOS GCD 的理解
GCD (Grand Central Dispatch) 是Apple公司开发的一种技术,它旨在优化多核环境中的并发操作并取代传统多线程的编程模式. 在Mac OS X 10.6和IOS 4.0之后开 ...
- java web-----DAO设计模式(数据库访问)
一,DAO设计模式用于 j2ee 的数据层访问,包括五部分, 数据库连接类(包含数据库的连接与关闭操作的一个类), VO类(私有变量与数据库表格对应,接收数据库中表格各字段内容), DAO接口类(包含 ...
- Cocos2d-x 3.0 cocostudio骨骼动画的动态换肤
概述 游戏中人物的状态会发生改变,而这种改变通常要通过局部的变化来表现出来.比如获得一件装备后人物形象的改变,或者战斗中武器.防具的损坏等.这些变化的实现就要通过动态换肤来实现.在接下来的这个Demo ...
- log4j使用细节
问题一:打印不同类的类名信息? 在log4j中通常是通过Logger.getLogger(class)指定所打印的类名,但是当我们需要打印不同类信息时,目前只能这样做,在不同的类文件中构建不同的log ...
- linux中python环境搭建及升级后yum不可用解决方案
1.1 LinuxCentOS 为例.1.1.1 升级 Python(1) 下载 Python 版本$ wget https://www.python.org/ftp/python/2.7.11/Py ...
- C++11中新特性之:initializer_list详解
C++11提供的新类型,定义在<initializer_list>头文件中. template< class T > class initializer_list; 先说它的用 ...