kasperstuck / htmldom
Laravel 4 简单的 HTML Dom 解析器
v1.0.0
2015-09-10 13:45 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-21 04:43:15 UTC
README
基于 Simple HTML Dom Parser 的 Laravel 4 和 5 的 Htmldom 包
安装
将以下行添加到 composer.json 文件的 require 部分:
{
"require": {
"yangqi/htmldom": "dev-master"
}
}
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>';