简体   繁体   中英

PHP simple_html_dom foreach

I'm getting html from different pages ($linkHtml) and want to get elements from those pages. With this I get Fatal error: Call to a member function find() on a non-object. If I move the second foreach out I get the result that I want from one page. How should I do to get the elements from all pages?

$url = 'http://page/';

foreach ($dataArray as $link) {
        $linkHtml = file_get_html($url . $link);

        foreach ($linkHtml->find('text') as $text) {

        }
}

I could't find any documentation on file_get_html() on php.net!? I would use

$doc = new DOMDocument();
$doc->loadHTML(file_get_contents($url . $link)));

file-get-contents

domdocument.loadhtml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM