我正在尝试解析一个维基百科页面,出于某种原因,下面的代码适用于所有维基百科页面(苹果维基百科页面除外!!)
include ('simple_html_dom.php');
$url = "http://en.wikipedia.org/wiki/Apple_Inc.";
$html = file_get_html($url);
$html以上的Strlen为苹果返回0以上。
注意:当$url设置为Microsoft的其他维基百科页面时,上面的代码工作得非常好-http://en.wikipedia.org/wiki/Microsoft-对于帝亚吉欧-http://en.wikipedia.org/wiki/Diageo等
我想使用file_get_html,这样我就可以将它放入DOM对象中并进一步处理它。
将simple_html_dom.php中的MAX_FILE_SIZE
常量更改为,例如
define('MAX_FILE_SIZE', 800000);
你可以去…:)这是在苹果页面的情况下获得"0"的方式。Strlen高于极限。。。
if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
return false;
}