2016-09-16 178 views
1

我试图从其他网站使用file_get_html()获取div内容。 当我连接到服务器时出现以下错误。file_get_html无效 - HTTP请求失败!请求被拒绝错误

警告:file_get_contents(http://www.example.com/view/204284808.php):无法打开流:HTTP请求失败! HTTP/1.0 999请求被拒绝

现在我的问题是如何解决这个问题或从服务器阻止的DOM操作?

我可以得到它吗?

<?php 
include_once('simple_html_dom.php'); 

$html = file_get_html('https://www.example.com/view/204284808.php'); 

$html = $html->find('div[class=lartz]', 0); 

echo $html; 

?> 

回答

0

可能是你必须在你的php.ini配置中启用allow_url_fopen。 或者,您可以使用cUrl。

相关问题