zoukankan      html  css  js  c++  java
  • perl lwp get uft-8和gbk

    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 $LANG
    en_US
    
    utf8编码:
    
    jrhmpt01:/root/lwp# echo $LANG
    en_US.UTF-8
    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->decoded_content;;
    };

  • 相关阅读:
    移动端rem布局
    父子组件通信
    拦截器
    Vue路由教程
    使用var和let的区别
    数组去重的几种方法
    利用位运算进行权限控制
    线程基础
    关于get请求的乱码问题
    nuxt.js Navigating to current location ("/xxx") is not allowed
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350888.html
Copyright © 2011-2022 走看看