Wednesday 5 July 2017

GET HTML (Parser) Using PHP

Download html parser class file from http://sourceforge.net/projects/simplehtmldom/files/

And create your project directory and create file index.php
 
 
 index.php 
 
<?php
error_reporting(0);
// call parser library
include('lib/simple_html_dom.php');
$html = file_get_html('http://webdeskers.com');
$posts = array();
foreach($html->find('tr') as $e)
{
  $data = array();
  foreach($e->find('td') as $d)
  {
   $data[] =  $d->innertext;
  }
  array_push($posts, $data);
}
 
echo "<pre>";
print_r($posts);
?>

No comments:

Post a Comment