ytekeli / dom-selector
An HTML DOM selector and extractor with using YAML config.
v0.2.0
2021-06-26 21:33 UTC
Requires
- php: ^7.3|^8.0
- ext-yaml: *
- paquettg/php-html-parser: ^3.1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.4
- phpstan/phpstan: ^0.12.90
- phpunit/phpunit: ^9.3.3
- rector/rector: ^0.11.23
This package is auto-updated.
Last update: 2024-10-27 05:09:55 UTC
README
An HTML DOM selector and extractor with using YAML config.
- Free software: MIT license
Requirements
- PHP ^7.3 | ^8.0
- ext-yaml
Install
Install the latest version using composer.
$ composer require ytekeli/dom-selector
This package can be found on packagist and is best loaded using composer. We support php 7.3, 7.4 and 8.0.
Example
You can find many examples of how to use the DOM Selector in the tests directory.
// Assuming you installed from Composer: require "vendor/autoload.php"; use DOMSelector\DOMSelector; $yaml_string = ' title: css: "h1" type: Text link: css: "h2 a" type: Link'; $selector = DOMSelector::fromYamlString($yaml_string); $extracted = $selector->extract('<h1>Title</h1><h2>Usage <a class="headerlink" href="https://example.com">ΒΆ</a></h2>'); print_r($extracted);
// output
Array
(
[title] => Title
[link] => https://example.com
)
We strongly inspired by selectorlib written with python.