PHP Classes
elePHPant
Icontem

Simple HTML DOM: Manipulate HTML elements using DOMDocument

Recommend this page to a friend!
  Info   View files Example   View files View files (67)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-10-29 (21 days ago) RSS 2.0 feedStarStarStarStar 75%Total: 387 This week: 1All time: 6,533 This week: 372Up
Version License PHP version Categories
voku-simple_html_dom 2.0.72MIT/X Consortium ...5.3HTML, PHP 5, Parsers
Collaborate with this project Author

simple_html_dom - github.com

Description

This class can manipulate HTML elements using DOMDocument

This is a fork of SimpleHTMLDOM package that uses DOMDocument classes instead of HTML string manipulation.

It can parse and tolerate invalid HTML and supports UTF-8 documents

It can search tags on a HTML page with selectors just like jQuery.

  Performance   Level  
Name: Lars Moelleken <contact>
Classes: 20 packages by
Country: Germany Germany
Age: 31
All time rank: 88356 in Germany Germany
Week rank: 17 Up2 in Germany Germany Up
Innovation award
Innovation award
Nominee: 9x

Winner: 1x

 

Details

Build Status Coverage Status Codacy Badge Latest Stable Version Total Downloads License Donate to this project using Paypal Donate to this project using Patreon

:scroll: Simple Html Dom Parser for PHP

A HTML DOM parser written in PHP - let you manipulate HTML in a very easy way! This is a fork of PHP Simple HTML DOM Parser project but instead of string manipulation we use DOMDocument and modern php classes like "Symfony CssSelector".

  • PHP 7.0+ Support
  • PHP-FIG Standard
  • Composer & PSR-4 support
  • PHPUnit testing via Travis CI
  • PHP-Quality testing via SensioLabsInsight
  • UTF-8 Support (more support via "voku/portable-utf8")
  • Invalid HTML Support (partly ...)
  • Find tags on an HTML page with selectors just like jQuery
  • Extract contents from HTML in a single line

Install via "composer require"

composer require voku/simple_html_dom
composer require voku/portable-utf8 # if you need e.g. UTF-8 fixed output

Quick Start

use voku\helper\HtmlDomParser;

require_once 'composer/autoload.php';

...
$dom = HtmlDomParser::str_get_html($str);
// or 
$dom = HtmlDomParser::file_get_html($file);

$element = $dom->findOne('#css-selector'); // "$element" === instance of "SimpleHtmlDomInterface"

$elements = $dom->findMulti('.css-selector'); // "$elements" === instance of SimpleHtmlDomNodeInterface<int, SimpleHtmlDomInterface>

$elementOrFalse = $dom->findOneOrFalse('#css-selector'); // "$elementOrFalse" === instance of "SimpleHtmlDomInterface" or false

$elementsOrFalse = $dom->findMultiOrFalse('.css-selector'); // "$elementsOrFalse" === instance of SimpleHtmlDomNodeInterface<int, SimpleHtmlDomInterface> or false
...

Examples

github.com/voku/simple_html_dom/tree/master/example

Support

For support and donations please visit Github | Issues | PayPal | Patreon.

For status updates and release announcements please visit Releases | Twitter | Patreon.

For professional support please contact me.

Thanks

  • Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
  • Thanks to StyleCI for the simple but powerfull code style check.
  • Thanks to PHPStan && Psalm for relly great Static analysis tools and for discover bugs in the code!

License

FOSSA Status

  Files folder image Files  
File Role Description
Files folder image.github (3 files)
Files folder imageexample (11 files)
Files folder imagesrc (1 directory)
Files folder imagetests (7 files, 1 directory)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpcs.php_cs Example Example script
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
  Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data
  Accessible without login Plain text file ISSUE_TEMPLATE.md Data Auxiliary data

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file example_advanced_selector.php Example Example script
  Accessible without login Plain text file example_basic_selector.php Example Example script
  Accessible without login Plain text file example_extract_html.php Example Example script
  Accessible without login Plain text file example_extract_meta_tags.php Example Example script
  Accessible without login Plain text file example_find_text.php Example Example script
  Accessible without login Plain text file example_modify_attribute.php Example Example script
  Accessible without login Plain text file example_modify_contents.php Example Example script
  Accessible without login Plain text file example_remove_comments.php Example Example script
  Accessible without login Plain text file example_remove_content.php Example Example script
  Accessible without login Plain text file example_scraping_imdb.php Example Example script
  Accessible without login Plain text file example_scraping_lebensmittelwarnung.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imagevoku (1 directory)

  Files folder image Files  /  src  /  voku  
File Role Description
Files folder imagehelper (23 files)

  Files folder image Files  /  src  /  voku  /  helper  
File Role Description
  Plain text file AbstractDomParser.php Class Class source
  Plain text file AbstractSimpleHtmlDom.php Class Class source
  Plain text file AbstractSimpleHtmlDomNode.php Class Class source
  Plain text file AbstractSimpleXmlDom.php Class Class source
  Plain text file AbstractSimpleXmlDomNode.php Class Class source
  Plain text file DomParserInterface.php Class Class source
  Plain text file HtmlDomParser.php Class Class source
  Plain text file SelectorConverter.php Class Class source
  Plain text file SimpleHtmlAttributes.php Class Class source
  Plain text file SimpleHtmlAttributesInterface.php Class Class source
  Plain text file SimpleHtmlDom.php Class Class source
  Plain text file SimpleHtmlDomBlank.php Class Class source
  Plain text file SimpleHtmlDomInterface.php Class Class source
  Plain text file SimpleHtmlDomNode.php Class Class source
  Plain text file SimpleHtmlDomNodeBlank.php Class Class source
  Plain text file SimpleHtmlDomNodeInterface.php Class Class source
  Plain text file SimpleXmlDom.php Class Class source
  Plain text file SimpleXmlDomBlank.php Class Class source
  Plain text file SimpleXmlDomInterface.php Class Class source
  Plain text file SimpleXmlDomNode.php Class Class source
  Plain text file SimpleXmlDomNodeBlank.php Class Class source
  Plain text file SimpleXmlDomNodeInterface.php Class Class source
  Plain text file XmlDomParser.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagefixtures (12 files)
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file HTML5DOMDocumentTest.php Class Class source
  Plain text file HtmlDomParserTest.php Class Class source
  Plain text file SimpleHtmlDomNodeTest.php Class Class source
  Plain text file SimpleHtmlDomTest.php Class Class source
  Plain text file TwigTest.php Class Class source
  Plain text file XmlDomParserTest.php Class Class source

  Files folder image Files  /  tests  /  fixtures  
File Role Description
  Accessible without login HTML file big.html Doc. Documentation
  Accessible without login HTML file horrible.html Doc. Documentation
  Accessible without login HTML file small.html Doc. Documentation
  Accessible without login HTML file test_mail.html Doc. Documentation
  Accessible without login HTML file test_mail_expected.html Doc. Documentation
  Accessible without login HTML file test_page.html Doc. Documentation
  Accessible without login HTML file test_page_plaintext.html Doc. Documentation
  Accessible without login Plain text file test_template.twig Data Auxiliary data
  Accessible without login Plain text file test_xml.xml Data Auxiliary data
  Accessible without login Plain text file test_xml_expected.xml Data Auxiliary data
  Accessible without login Plain text file test_xml_replace_expected.xml Data Auxiliary data
  Accessible without login HTML file windows-1252-example.html Doc. Documentation

Downloadvoku-simple_html_dom-2019-10-29.zip 168KB
Downloadvoku-simple_html_dom-2019-10-29.tar.gz 136KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Portable UTF-8 Download .zip .tar.gz Strin Required
 Version Control Reuses Unique User Downloads Download Rankings  
 100%3
Total:387
This week:1
All time:6,533
This week:372Up
User Ratings User Comments (1)
 All time
Utility:93%StarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:93%StarStarStarStarStar
Examples:93%StarStarStarStarStar
Tests:-
Videos:-
Overall:75%StarStarStarStar
Rank:131
 
nice
3 years ago (muabshir)
80%StarStarStarStarStar