【问题标题】:file_get_html not works - HTTP request failed! Request denied Errorfile_get_html 不起作用 - HTTP 请求失败!请求被拒绝错误
【发布时间】:2016-09-16 05:53:58
【问题描述】:

我正在尝试使用 file_get_html() 从其他网站获取 div 内容。 当我连接到服务器时出现以下错误。

警告: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;

?>

【问题讨论】:

    标签: php file dom get


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2015-07-29
      • 2023-02-01
      • 2019-06-15
      • 2012-03-16
      • 2015-04-10
      • 2022-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多