Ask Curl collect ebay garbled how to solve?

Source: Internet
Author: User
Dear friends, I now use curl to collect information, found that the collection of ebay store information is always displayed as garbled, such as:

$url = "http://stores.ebay.com/sportingamerica/";
$caiji =curl_get_contents ($url);
Print_r ($caiji);
Can any of the friends explain? Thank you!

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;
}

Encoding should be no problem, my php file encoding is Utf-8,ebay page encoding is also utf-8 AH.


Reply to discussion (solution)

Data was compressed by gzip

Set this curl_setopt ($ch, curlopt_encoding, 1);
Or read back after Echo Gzdecode ($caiji);

You can set the return code after getting the encoding format to TEXT/UTF8 format, so see if it is possible.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.