Code Monkey home page Code Monkey logo

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.

Simple HTML DOM Community's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.