Simple HTML DOM is a PHP library to parse data from webpages, in short you can use this library to do web scraping using PHP and even store data to MySQL database. Simple HTML DOM has following features:
- The parser library is written in PHP 5+.
- It requires PHP 5+ to run.
- Parser supports invalid HTML parsing.
- It allows to select html tags like Jquery way.
- Supports Xpath and CSS path based web extraction.
- Provides both the way – Object oriented way and procedure way to write code.
Scraping all links
<?php
//Brought to you by http://www.webdata-scraping.com
include "simple_html_dom.php";
//create object
$html=new simple_html_dom();
//load specific URL
$html->load_file("http://www.google.com");
// This will Find all links
foreach($html->find('a') as $element)
echo $element->href . '
';
?>