yangqi / htmldom
该包已被废弃且不再维护。未建议替代包。
适用于Laravel 4的简单HTML Dom解析器
v1.0.0
2015-09-10 13:45 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2022-04-02 02:10:45 UTC
README
一个基于Simple HTML Dom Parser的Laravel 4和5的Htmldom包
安装
将以下行添加到composer.json
中的require
部分。
{ "require": { "yangqi/htmldom": "1.0.*" } }
Laravel 5配置(与Laravel 4相同)
- 将服务提供者添加到
config/app.php
。
'providers' => array( ... 'Yangqi\Htmldom\HtmldomServiceProvider', ...
- 在
config/app.php
中添加别名。
'aliases' => array( ... 'Htmldom' => 'Yangqi\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>';