A simple PHP HTML DOM parser written in PHP5+, supports invalid HTML, and provides a very easy way to find, extract and modify the HTML elements of the DOM. jQuery like syntax allow sophisticated finding methods for locating the elements you care about.
Download simple_html_dom.php from here : https://sourceforge.net/projects/simplehtmldom/files/
FYI : You are not suggested to scrap contents from third party websites or webpages. This is just for educational purpose. However, you are try this on our own webpage or sites.
Source Code :
<?php include('simple_html_dom.php'); $html = file_get_html('https://reeteshghimire.com.np/'); $titles = array(); foreach($html->find('.entry-title') as $t){ $titles[] = $t->innertext; } $images = array(); foreach($html->find('img') as $i){ $images[] = '<img width="200" src="'.$i->src.'">'; } $titles = array_filter(array_unique($titles)); echo "<pre>"; print_r($titles); print_r($images); ?>
Follow this video for complete guidance :