This url
''
在浏览器中工作得很好,但 cURL 返回错误 3(格式错误的 url)。
关于解决方法有什么想法吗?
EDIT:
卷曲代码:
function get_web_page( $url )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
if (!$errmsg =='') {die($err.':'.$errmsg);}
return $content;
}
运行时我得到页面的输出
curl http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=39726387
这也适用于我:
$ch = curl_init('http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=39726387');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = curl_exec($ch);
curl_close($ch);
echo $out;
编辑:刚刚尝试了您发布的代码,它对我来说效果很好。也许您要传递的字符串get_web_page()
是错的?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)