simple_html_dom响应为空

问题描述:

我在使用HTML DOM时遇到了某些网页的问题。我设置了用户代理并打开一个流,但响应似乎是空的。simple_html_dom响应为空

我注意到这些网页的一些内容是HTML中有未封闭的标签。这可能会影响简单的HTML DOM?

我的代码是:

<?php 

include_once 'simple_html_dom.php'; 

$url_to_compare = 'http://www.idigic.net/buy-instagram-followers/'; 

ini_set('user_agent', $_SERVER['HTTP_USER_AGENT']); 

$html = file_get_html($url_to_compare)->plaintext; 

echo $html; 

?> 
+0

_“这可能会影响简单的HTML DOM?”_它可以。你可以尝试用['tidy :: repairString()'](http://us3.php.net/manual/en/tidy.repairstring.php)清理HTML。 –

+0

不工作! @AlexHowansky –

+0

尝试使用卷曲。我也不认为'ini_set'会做任何事情。 – pguardiario

检查此链接

http://simplehtmldom.sourceforge.net/manual.htm

我认为这是要紧妳。

file_get_html其获取数组,因此它不会在echo中显示任何内容。使用print_r可能是工作。

+1

请[仅限链接回答](http://meta.*.com/tags/link-only-answers/info)。答案是“几乎不超过链接到外部网站”[可能会被删除] – Quentin

+0

Print_r确实会返回一些内容,但我无法访问任何元素或明文渲染一切无用。 –