【发布时间】:2014-05-18 21:28:06
【问题描述】:
大家好,我有这个代码:
<?php
include './simple_html_dom.php';
//this link exists
$teste = new simple_html_dom("http://www.btolinux.com.br/");
echo $teste->original_size."<br>";
if($teste->original_size !== 0){
$teste->find("html");
}
//At this time I'm forcing get a 404 error link.
$teste = new simple_html_dom("http://www.btolinux.com.br/error/");
echo $teste->original_size."<br>";
if($teste->original_size !== 0){
$teste->find("html");
}
//Now I'm get the correct link again. Why the error persists?
$teste = new simple_html_dom("http://www.btolinux.com.br/");
echo $teste->original_size."<br>";
if($teste->original_size !== 0){
$teste->find("html");
}
?>
因此,在我的代码中,当我发现一个 404 错误链接时,在使用同一类创建的下一个对象中,错误仍然存在。 我该如何解决这个问题?
要尝试此代码,请获取 http://sourceforge.net/projects/simplehtmldom/files/ 中的 Simple_dom_php
【问题讨论】:
-
能否详细解释一下
-
此代码将此错误返回给我:“致命错误:在第 1113 行的 /var/www/html/crawler/simple_html_dom.php 中的非对象上调用成员函数 find()”我的 PHP 版本是 5.5.9-1ubuntu4 (cli)
标签: php web-crawler simple-html-dom