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.