perl lwp get uft-8和gbk

来源:互联网 发布:战舰世界 数据更新出错 编辑:程序博客网 时间:2024/06/04 17:42
gbk编码:jrhmpt01:/root/lwp# cat x2.pl use  LWP::UserAgent;use DBI;$user="root";$passwd='R00t,uHagt.0511';$dbh="";$dbh = DBI->connect("dbi:mysql:database=zjzc_vote;host=114.55.5.57;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;$dbh->do("SET NAMES utf8");use POSIX;use Data::Dumper;use HTML::TreeBuilder;my $ua = LWP::UserAgent->new;$ua->timeout(10);$ua->env_proxy;$ua->agent("Mozilla/8.0");my $response = $ua->get('http://data.10jqka.com.cn/financial/yjyg/date/2016-03-31/ajax/1/');if ($response->is_success) {print   $response->content;};jrhmpt01:/root/lwp# echo $LANGen_USutf8编码:jrhmpt01:/root/lwp# echo $LANGen_US.UTF-8jrhmpt01:/root/lwp# cat x2.pl use  LWP::UserAgent;use DBI;$user="root";$passwd='R00t,uHagt.0511';$dbh="";$dbh = DBI->connect("dbi:mysql:database=zjzc_vote;host=114.55.5.57;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;$dbh->do("SET NAMES utf8");use POSIX;use Data::Dumper;use HTML::TreeBuilder;my $ua = LWP::UserAgent->new;$ua->timeout(10);$ua->env_proxy;$ua->agent("Mozilla/8.0");my $response = $ua->get('http://data.10jqka.com.cn/financial/yjyg/date/2016-03-31/ajax/1/');if ($response->is_success) {print   $response->decoded_content;;};

0 0