zoukankan      html  css  js  c++  java
  • $response->decoded_content 和$response->content

       print $response->decoded_content;
       print $response->content;
    
    
    GBK 环境:
    
    
    
    
      my  $user="root";  
      my  $passwd="1234567";  
      $dbh = DBI->connect("dbi:mysql:database=licai;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;  
      $dbh->do("SET NAMES utf8"); 
       my $ua = LWP::UserAgent->new;  
       $ua->timeout(10);  
       $ua->env_proxy;  
       $ua->agent("Mozilla/8.0");  
       my $response = $ua->get('https://licai.yingyinglicai.com/product/list.htm') || die;  
           #print $response->decoded_content;
           print $response->content;
    
    
    
    use Encode;
      my  $user="root";  
      my  $passwd="1234567";  
      $dbh = DBI->connect("dbi:mysql:database=licai;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;  
      $dbh->do("SET NAMES utf8"); 
       my $ua = LWP::UserAgent->new;  
       $ua->timeout(10);  
       $ua->env_proxy;  
       $ua->agent("Mozilla/8.0");  
       my $response = $ua->get('https://licai.yingyinglicai.com/product/list.htm') || die;  
           my $str= $response->decoded_content;
             $str=encode_utf8("$str");
            $str=  encode("gbk",decode("utf8","$str"));
            print $str;
           #print $response->content;
    node2:/root/pachong/yylc#
    正常
    
    
    
       my $response = $ua->get('https://licai.yingyinglicai.com/product/list.htm') || die;  
          print $response->decoded_content;
    
       乱码:
    
    
    
    
    $mess->content( $bytes )
    The content() method sets the raw content if an argument is given. If no argument is given the content is not touched. In either case the original raw content is returned.
    
    Note that the content should be a string of bytes. Strings in perl can contain characters outside the range of a byte. The Encode module can be used to turn such strings into a string of bytes.
    
    
    
    content()方法设置 原始内容 如果一个参数被给定。
    
    如果没有参数给定,在任何一种情况 原始raw内容是被返回。
    
    
    
    注意 内容应该是一个字符串, 字符串在Perl可以包含字符 在一个字节范围之外。
    
    Encode 模块可以用于转换这样的字符串为 字节字符串
    
    
    $mess->decoded_content( %options ):
    
    
    

  • 相关阅读:
    doc文档生成带目录的pdf文件方法
    Android uses-permission 权限大全
    AndroidManifest.xml配置文件详解 (转)
    解决导入Android例子时“Unable to resolve target 'android-x' ”的错误
    Eclipse导入Android项目的方法(转)
    数据结构与算法问题 AVL二叉平衡树
    TinyXml 与 Rapidxml效率对照
    HDU 1176-免费馅饼(DP_逆推)
    【OpenCV新手教程之十四】OpenCV霍夫变换:霍夫线变换,霍夫圆变换合辑
    交换机基础
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349799.html
Copyright © 2011-2022 走看看