请问curl采集ebay乱码怎样解决

WBOY
Release: 2016-06-13 12:08:28
Original
871 people have browsed it

请教curl采集ebay乱码怎样解决?
各位朋友,我现在使用curl采集信息,发现采集ebay店铺信息时老是显示为乱码,比如:

$url="http://stores.ebay.com/sportingamerica/";
$caiji=curl_get_contents($url);
print_r($caiji);
哪位朋友能否解释下?谢谢!

function curl_get_contents($url)
{
    $ch = curl_init();   
    curl_setopt($ch, CURLOPT_URL, $url);              
    //curl_setopt($ch,CURLOPT_HEADER,1);            
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);          
    curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);      
    curl_setopt($ch, CURLOPT_REFERER,_REFERER_);       
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);     
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);        
    $r = curl_exec($ch);   
    curl_close($ch);   
    return $r;   
}

编码应该没有问题,我的php文件编码是utf-8,ebay的页面编码也是utf-8的啊。


------解决思路----------------------
数据被 gzip 压缩了

设置这个    curl_setopt($ch, CURLOPT_ENCODING, 1); 
或读回后  echo gzdecode($caiji);


------解决思路----------------------
你可以设置获取后的返回代码编码格式为text/utf8格式,这样看看可不可以。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!