larammerce / html-dom
Simple Html Dom Parser for Laravel 8
v1.1.1
2022-01-13 22:32 UTC
Requires
- php: ^8.0
- illuminate/support: ^8
This package is auto-updated.
Last update: 2024-04-14 03:23:12 UTC
README
A HtmlDom package for Laravel 8 based on Simple HTML Dom Parser
Installation
Add the following line to the require
section of composer.json
:
{ "require": { "larammerce/html-dom": "1.1.*" } }
Laravel 8 Setup
- Add the service provider to
config/app.php
.
'providers' => array( ... 'Larammerce\HtmlDom\HtmlDomServiceProvider', ...
- Add alias to
config/app.php
.
'aliases' => array( ... 'HtmlDom' => 'Larammerce\HtmlDom\HtmlDom', ...
Usage
- Use following:
$html = new \HtmlDom('http://www.example.com'); // Find all images foreach($html->find('img') as $element) echo $element->src . '<br>'; // Find all links foreach($html->find('a') as $element) echo $element->href . '<br>';
See the detailed documentation http://simplehtmldom.sourceforge.net/manual.htm