duanjue9889 2014-12-19 22:15
浏览 104
已采纳

php curl显示不可读的标志

My Curl-code works:

$ch = curl_init();
$header = array(
  'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',
  'Accept-Language: en-us;q=0.8,en;q=0.6'
);
$options = array(
  CURLOPT_URL => $url, 
  CURLOPT_HEADER => 0, 
  CURLOPT_RETURNTRANSFER => 1, 
  CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13',
  CURLOPT_HTTPHEADER => $header
  );
curl_setopt_array($ch, $options);
$str = curl_exec($ch);
curl_close($ch);

But from one page only I get signs start so:

‹�������í}ëvâH²îïîµö;dk¦}™² ...

I detect with mb_detect_encoding that it is an utf8-string. I'm confused, why can't I read the source code like from other sites?

The site I want to curl is http://stores.ebay.com/artlines-2012

Thank you.

  • 写回答

1条回答 默认 最新

  • doupang9080 2014-12-19 22:28
    关注

    It looks like an encoding issue. Try adding CURLOPT_ENCODING.

    Example:

    curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等