2012-05-16 31 views
1

我試圖通過file_get_html獲取某個網頁的內容。file_get_html獲取一個空頁面

事情是,我設法做到這一點,但現在它給了我一個空的結果沒有任何錯誤消息。

file_get_contents('http://www.google.com') or die('this is not a valid url'); 

該網址是有效的。我把它粘貼到我的瀏覽器上。

我試着玩了USER_AGENT:

ini_set('user_agent', 'My-Application/2.5'); 

甚至

ini_set('user_agent', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.24 (KHTML like Gecko) Chrome/19.0.1055.1 Safari/535.24'); 

但沒有.. 有什麼建議?

+0

什麼是它的返回值,當您叫它? – nullpotent

回答

0

嘗試file_get_contents

這將是這樣的:

$input=file_get_contents("http://www.google.com"); 
$input=htmlspecialchars($input); 
echo $input; 
0

在php.ini中啓用 「allow_url_fopen選項」,代碼精

+0

你好,它已經啓用了嗎?其他建議?似乎無論我能拉什麼東西,或者我什麼都不能拉。這可能是因爲該網站正在蒐集我的IP嗎? – devmonster

相關問題