$html = file_get_html('http://example.com/'); // Load HTML file $links = $html ->find('a'); // Find all links in the document foreach($links as $link){ echo $link->href . '
'; // Print the href attribute of each link }
$html = file_get_html('http://example.com/'); // Load HTML file $images = $html->find('img[alt]'); // Find all images with alt text in the document foreach($images as $image){ echo $image->src . 'The above examples demonstrate the use of the `find` method provided by the simple_html_dom library. This method takes a CSS selector as an argument and returns an array of elements that match the selector. The simple_html_dom library is a third-party package and can be installed via Composer. The package name is `sunra/php-simple-html-dom-parser`.
'; // Print the src attribute of each image }