simplehtmldom is a fast and reliable HTML DOM parser for PHP.
simplehtmldom requires PHP 5.6 or higher with ext-iconv enabled. Following extensions enable additional features of the parser:
HtmlWeb
.Manually:
Download the latest release from SourceForge and extract the files in the vendor folder of your project.
Composer:
composer require simplehtmldom/simplehtmldom
Git:
git clone git://git.code.sf.net/p/simplehtmldom/repository simplehtmldom
Note: The GitHub repository serves as a mirror for the SourceForge project. We currently accept pull requests and issues only via SourceForge.
This example illustrates how to return the page title:
<?php
include_once 'HtmlWeb.php';
use simplehtmldom\HtmlWeb;
$client = new HtmlWeb();
$html = $client->load('https://www.google.com/search?q=simplehtmldom');
// Returns the page title
echo $html->find('title', 0)->plaintext . PHP_EOL;
<?php
include_once 'vendor/autoload.php';
use simplehtmldom\HtmlWeb;
$client = new HtmlWeb();
$html = $client->load('https://www.google.com/search?q=simplehtmldom');
// Returns the page title
echo $html->find('title', 0)->plaintext . PHP_EOL;
Find more examples in the installation folder under examples
.
The documentation for this library is hosted at https://simplehtmldom.sourceforge.io/docs/
There are various ways for you to get involved with simplehtmldom. Here are a few:
If you want to contribute code to the project, please open a feature request and include your patch with the message.
The source code for simplehtmldom is licensed under the MIT license. For further information read the LICENSE file in the root directory (should be located next to this README file).
simplehtmldom is a purely PHP-based DOM parser that doesn't rely on external libraries like libxml, SimpleXML or PHP DOM. Doing so provides better control over the parsing algorithm and a much simpler API that even novice users can learn to use in a short amount of time.