fafmiardi / htmldom
为 Laravel 4 设计的简单 HTML Dom 解析器
1.0
2015-05-06 08:35 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-18 08:39:04 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>';