Menu

Tree [b8d048] master /
 History

HTTPS access


File Date Author Commit
 .github 2022-04-05 logmanoriginal logmanoriginal [de6e37] .github: Add PHP compatibility check to workflow
 .mkdocs 2022-04-07 logmanoriginal logmanoriginal [a17ec8] Fix spelling mistakes.
 docs 2022-04-18 logmanoriginal logmanoriginal [7a5b98] docs: Include recent changes
 example 2022-04-07 logmanoriginal logmanoriginal [c2e1e7] examples: Initialize $data variable
 tests 2022-04-25 logmanoriginal logmanoriginal [b8d048] HtmlNode: Replace and collapse unicode whitespa...
 .gitattributes 2019-10-24 logmanoriginal logmanoriginal [8db570] Add .travis.yml to .gitignore
 .gitignore 2022-04-06 logmanoriginal logmanoriginal [1b013d] Reorganize docs
 CHANGELOG.md 2022-04-07 logmanoriginal logmanoriginal [a17ec8] Fix spelling mistakes.
 Debug.php 2022-04-04 logmanoriginal logmanoriginal [3c4806] Fix coding style violations
 HtmlDocument.php 2022-04-24 logmanoriginal logmanoriginal [c53a61] HtmlDocument: Use try-catch block for iconv
 HtmlElement.php 2022-04-06 logmanoriginal logmanoriginal [58aad2] Add new class to handle HTML elements
 HtmlNode.php 2022-04-25 logmanoriginal logmanoriginal [b8d048] HtmlNode: Replace and collapse unicode whitespa...
 HtmlWeb.php 2022-04-01 logmanoriginal logmanoriginal [dddb4f] HtmlWeb: Accept all supported encodings when us...
 LICENSE 2019-04-15 logmanoriginal logmanoriginal [337845] Add license and copyright statement
 README.md 2022-04-05 logmanoriginal logmanoriginal [981b97] README: Replace Travis-CI bage by GitHub Workfl...
 composer.json 2022-04-06 logmanoriginal logmanoriginal [1b013d] Reorganize docs
 composer.lock 2022-04-05 logmanoriginal logmanoriginal [b3ce6b] composer: Downgrade phpcs to version 2.x
 constants.php 2022-03-27 logmanoriginal logmanoriginal [791012] Replace define with const syntax
 mkdocs.yml 2022-04-18 logmanoriginal logmanoriginal [7a5b98] docs: Include recent changes
 phpcompatibility.xml 2022-04-06 logmanoriginal logmanoriginal [1b013d] Reorganize docs
 phpcs.xml 2022-04-06 logmanoriginal logmanoriginal [1b013d] Reorganize docs
 phpunit.xml 2022-04-07 logmanoriginal logmanoriginal [d5ead3] phpunit: Remove unnecessary default value assig...
 release.sh 2022-04-07 logmanoriginal logmanoriginal [a17ec8] Fix spelling mistakes.
 simple_html_dom.php 2022-04-07 logmanoriginal logmanoriginal [a17ec8] Fix spelling mistakes.

Read Me

PHP Simple HTML DOM Parser

LICENSE
RELEASE
BASIC TESTS
PACKAGIST

simplehtmldom is a fast and reliable HTML DOM parser for PHP.

Key features

  • Purely PHP-based DOM parser (no XML extensions required).
  • Works with well-formed and broken HTML documents.
  • Loads webpages, local files and document strings.
  • Supports CSS selectors.

Requirements

simplehtmldom requires PHP 5.6 or higher with ext-iconv enabled. Following extensions enable additional features of the parser:

  • ext-mbstring (recommended) \
    Enables better detection for multi-byte documents.
  • ext-curl \
    Enables cURL support for the class HtmlWeb.
  • ext-openssl (recommended when using cURL) \
    Enables SSL support for cURL.

Installation

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.

Usage

This example illustrates how to return the page title:

Manually
<?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;
Using composer
<?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.

Documentation

The documentation for this library is hosted at https://simplehtmldom.sourceforge.io/docs/

Getting involved

There are various ways for you to get involved with simplehtmldom. Here are a few:

  • Share this project with your friends (Twitter, Facebook, ...you name it...).
  • Report bugs (SourceForge).
  • Request features (SourceForge).
  • Discuss existing bugs, features and ideas.

If you want to contribute code to the project, please open a feature request and include your patch with the message.

Authors

License

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).

Technical notes

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.