// Load the HTML document $html = file_get_html('http://www.example.com/'); // Find all the links in the document $links = $html->find('a'); // Print all the links foreach($links as $link) { echo $link->href . "
"; }
// Load the HTML document $html = file_get_html('http://www.example.com/'); // Find all the images in the document $images = $html->find('img'); // Print all the images foreach($images as $image) { echo $image->src . "
"; }
// Load the HTML document $html = file_get_html('http://www.example.com/'); // Find the title of the document $title = $html->find('title', 0)->plaintext; // Print the title echo $title;These examples use PHP Simple HTML DOM to extract specific elements from an HTML document. The package library used in these examples is PHP Simple HTML DOM.