Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php在尝试获取url web scrape的下一页时从simplehtmldom获取错误_Php_Url_Web Scraping_Scrape_Simple Html Dom - Fatal编程技术网

php在尝试获取url web scrape的下一页时从simplehtmldom获取错误

php在尝试获取url web scrape的下一页时从simplehtmldom获取错误,php,url,web-scraping,scrape,simple-html-dom,Php,Url,Web Scraping,Scrape,Simple Html Dom,我试图进入主题的下一页,但它给出了一个错误。有没有办法避免这个错误,以便能够在该年龄段的主题中刮取下一页?(下一页是20,之后是40等等)下面给出了错误,我肯定有人会要求我发布代码,但不确定我应该发布多少或什么代码 20 1 1.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

我试图进入主题的下一页,但它给出了一个错误。有没有办法避免这个错误,以便能够在该年龄段的主题中刮取下一页?(下一页是20,之后是40等等)下面给出了错误,我肯定有人会要求我发布代码,但不确定我应该发布多少或什么代码

20 1 1.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\u get\u html('http://www.google.com/');
    -当然,你的线路上会有你想要的网址

  • 我认为问题在于您可能没有包含simple\u html\u dom,或者您缺少文件\u get\u html

    检查一下。问题不在simplehtmldom.php中,所以请查看您创建的文件

    祝你好运

    更新

    当你在做的时候。请在您的文件中提供源代码,或者至少提供调用find()的行。

    您是否检查了正在调用
    find()
    的外观对象的类型?@merrill-您可以先发布第870到885行吗。还有,看看亚历克斯说了些什么。@Dimitar Dimitrov刚刚发布了870-885这一行,我不确定上面提到的是哪一种find()类型的亚历克斯。我猜他指的是你提到的字里行间的find()。谢谢,但也包括在内。我能够刮除所有类别和第一个类别的第一页,但不能刮除下一页,因为下一页出现了错误。我在之前的抓取(diff.site)中遇到了一个非常类似的问题,并将simplehtmldom中的1375行更改为“if(!is_null($this->root)){'更改后,它可以刮到该类别的下一页。@merrill-首先,如果我的建议冒犯了你,我很抱歉。我写这篇文章时很匆忙,尽管我编辑了好几次,但我再也没有读过你的原始文章。如果这是一个特殊情况,请将其提交给simplehtmldom的错误跟踪系统,以便我们可以所有好处。也感谢您的洞察力。