冰风飒的博客

php的扩展curl抓取网页时发生500错误

php的扩展curl抓取网页时发生500错误 代码为标准的curl。但是居然发生服务器500错误,百思不得其解。 [php] $url = "http://www.youdao.com/smartresult-xml/search.s?type=ip&q={$ip}"; #echo $u;die; #echo Utility::HttpRequest($u); $timeout = $abort ? 1 : 2; $ch = curl_init(); #$url = 'http://www.youdao.com'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_REFERER,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $result = curl_exec($ch); [/php] 后来把函数单独拿出来的时候,又真长了。可能的原因是服务器url发生301移动时可能产生的,在这里做个记号

posted on 2012-08-09 10:48  冰风飒  阅读(841)  评论(0编辑  收藏  举报

导航