2010-01-24 79 views
6

此網址捲曲 '惡意網址'

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

工作得很好的瀏覽器,但捲曲回報的錯誤3(惡意URL)。

任何關於解決問題的想法?

編輯:

捲曲代碼:

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; 
} 
+1

當我通過cURL加載它時,該URL顯示工作正常。你能提供你的PHP代碼嗎? – zombat 2010-01-24 07:38:02

+0

你應該檢查url是否爲空。 – SuperBear 2016-04-01 10:46:54

+0

我的問題是,我傳遞了錯誤的變量來捲曲......它不是一個URI。張貼這個評論,以防萬一別人花了2個小時尋找什麼是錯誤的,只是爲了找出那個菜鳥的錯誤。 :) – 2016-10-22 09:03:06

回答

8

運行

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; 

編輯:剛剛嘗試過你的合作de貼,它對我來說工作得很好。也許你傳遞到get_web_page()的字符串是錯誤的?

+0

WARGH ...那你在上午6點得到的編碼...我寫了$ POST _....對不起,恐慌了:) – Mark 2010-01-24 07:54:43