看下面的代码,在本地appach服务器可以正常打印出页面内容,但是到服务器上却提示15s 的timeout错误:
$htmlstr = get_html("http://detail.tmall.com/item.htm?id=41159437194");
echo $htmlstr;
function get_html( $url )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT,120);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//302redirect
$content = curl_exec($ch);
curl_close($ch);
return $content;
}