Wednesday, September 26, 2012

PHP Simple HTML DOM Parser



PHP simple HTML DOM Paser can be downloaded from:
http://sourceforge.net/projects/simplehtmldom/

Example:
http://simplehtmldom.sourceforge.net/

PHP Simple HTML DOM Parser:
  • A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way!
  • Require PHP 5+.
  • Supports invalid HTML.
  • Find tags on an HTML page with selectors just like jQuery.
  • Extract contents from HTML in a single line.
My example  to extract a swf link for a flash website as following test.php
 <?php
 // Create DOM from URL or file
 include_once('simple_html_dom.php');
$html = file_get_html('http://www.flash88.net/WishList/2012/9/2/List_1870.html');
// Find all images
foreach($html->find('EMBED') as $element)
      echo $element->src . '<br>';
?>


Return:
http://www.flash88.net/flash882004y12y9auto3ty//mtv/85.swf

1 comment:

  1. Thanks for your grateful informations, this blogs will be really help for PHP tutorial.

    ReplyDelete