PHP Curl Print Problem
I'm trying to print an external site's HTML using curl, but when I go to print the html I just get a bunch of bad characters:
D\ÓLþ¢GΖ´ï!ñ{HÑ,Jþ»H¹§L+÷53j?‰²î¡<‘*tÜe÷uÖbìê~Æô¬²c˜‹§ ~áäÆL#f?ⶊªþU™á˜ÉÉOæ{^¤ëaÀ Tê"1Û¨Dtî’œxˆk‘:@ŽD5î:'¶e\*³q‘׸`…±¾ôäó÷ð1j7þä‘åQ6®9bcxã„A2ã—-ÇøüåÉò÷2{ÂÐe桢ǙŒÄg©Az!Ø¡>±zךÂ+;f RZÛÝ€ížáÒžHa¬¢Æ'ë•ñ þ=Ð=ºtyšÖâå'ÇpžÄ¦ÆN½€5½roåðFe¹)ˆš`ØnhŠy(GÆÔ} Bu7H¥JzÐ iVê÷áÆ”øG>6HÿUµÞhµj YH-ÌaaEÚx±‰…Êâ£-ûeÎqCÆLÌå㘎‰†LÐÆM I]€a)Ï.$—ÅH••£ ŒŒ’ªÉ;cŽc(i´¥!I]‹€„³tFc^ë'€e±øÉ_øß
Here is my code:
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://www.thesite.com/");
curl_setopt($curl,开发者_运维知识库 CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
print $result;
Any help would be great,
Thanks!
If the response is GZIP'd, you may use this:
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
See: http://www.php.net/manual/en/function.curl-setopt.php
To see if it's gzip'd, check the headers (see CURLOPT_HEADER
).
精彩评论