erivello / simple-html-dom-bundle
围绕Simple HTML DOM库的组件
dev-master
2013-12-07 15:31 UTC
Requires
- php: >=5.3.3
- symfony/browser-kit: 2.*
- symfony/finder: 2.*
- symfony/form: 2.*
- symfony/framework-bundle: 2.*
- symfony/yaml: 2.*
This package is auto-updated.
Last update: 2024-09-27 21:48:01 UTC
README
此组件提供了Simple HTML DOM解析器的简单集成到Symfony2中。Simple HTML DOM解析器是一个PHP5+编写的HTML DOM解析器,允许您像jQuery一样使用选择器来操作HTML,查找HTML页面上的标签,并从HTML中提取内容。
安装
安装非常简单,它使用了Composer。
将SimpleHtmlDomBundle添加到您的composer.json中
"require": {
"erivello/simple-html-dom-bundle": "dev-master"
}
在app/AppKernel.php
中注册该组件
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Erivello\SimpleHtmlDomBundle\ErivelloSimpleHtmlDomBundle(), ); }
使用
您可以通过simple_html_dom
服务访问SimpleHtmlDomBundle
<?php $parser = $this->container->get('simple_html_dom'); $parser->load('http://www.google.com/'); // Find all links foreach($parser->find('a') as $element) { echo $element->href . '<br/>'; }
许可协议
SimpleHtmlDomBundle遵循MIT许可协议。