kalimeromk / update-htmldom
为Laravel设计的简单HTML DOM解析器
v1
2022-10-10 06:21 UTC
Requires
- php: ^7.3|^7.4|^8.0|^8.1
- ext-iconv: *
This package is auto-updated.
Last update: 2024-09-10 10:47:08 UTC
README
基于Simple HTML Dom Parser的Laravel 5到9的Htmldom包
安装
将以下行添加到composer.json
的require
部分
composer require kalimeromk/update-htmldom
Laravel 5配置
- 将服务提供者添加到
config/app.php
。
'providers' => array( ... 'Htmldom\HtmldomServiceProvider', ...
- 在
config/app.php
中添加别名。
'aliases' => array( ... 'Htmldom' => 'Htmldom\Htmldom', ...
使用方法
- 使用以下方法
$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>';}
查看详细文档http://simplehtmldom.sourceforge.net/manual.htm
s