2012-05-16 81 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

相关问题