在PHP的curl代码中增加header可解决此问题。
$header = array( "Host: 你的域名(不能包含http://)", "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.3", "Accept-Encoding: gzip,deflate,sdch", "Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4", "Cache-Control: max-age=0", "Connection: keep-alive", ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1/'.$url);//必须 curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//必须
如果乱码,可以把中文转码,另外如果页面被gzip压缩,就要增加以下代码
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');