Simple HTML parser using PHP


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 :

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 :


$html = file_get_html('');

$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>";

Follow this video for complete guidance :

ALSO READ  Realtime Air Quality Index (AQI) Fetch API

Comments are closed.