gpt4 book ai didi

php - curl 'malformed url'

转载 作者:行者123 更新时间:2023-12-02 04:16:30 28 4
gpt4 key购买 nike

这个网址

'http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=39726387 '

在浏览器中工作得很好,但 cURL 返回错误 3(网址格式错误)。

有什么解决办法吗?

编辑:

cURL 代码:

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() 的字符串是错误的?

关于php - curl 'malformed url',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2126300/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com