我试图得到主题的下一页,但它给出了一个错误。有什么方法可以避免这种错误,以便能够在该年龄主题内抓取下一页?(下一页是20,之后是40等等)错误如下,我确信有人会要求我把代码,但不确定我应该张贴多少或什么代码。
http://blah.com/quotes/topic/age20 11 http://blah.com/quotes/topic/age/20
Fatal error: Call to a member function find() on a non-object in /Users/blah/Sites/simple_html_dom.php on line 879
更新* * * 这是870-885之间的行
function save($filepath='') {
$ret = $this->root->innertext();
if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX);
return $ret;
}
// find dom node by css selector
// Paperg - allow us to specify that we want case insensitive testing of the value of the selector.
function find($selector, $idx=null, $lowercase=false) {
return $this->root->find($selector, $idx, $lowercase);
}
// clean up memory due to php5 circular references memory leak...
function clear() {
foreach ($this->nodes as $n) {$n->clear(); $n = null;}
应该检查的第一件事是调用$html->find()的文件。
-
检查是否在文件开头包含了simple_html_dom.php(带有include)
-确保它在那里
-确保路径正确 -
检查你是否有这样一行:$html = file_get_html('http://www.google.com/');
-当然你的行会有你想要获取的网址
我认为问题是你可能没有包括simple_html_dom或你错过了file_get_html。
检查这些。问题不在simplehtmldom.php中,所以请查看您创建的文件。
祝你好运!
更新
既然你这么做了。请在文件中提供源代码,或者至少在调用find()的那一行。