pmvc-plugin / html_parser
HTML parser
0.1.11
2018-04-21 23:27 UTC
Requires
- pmvc/pmvc: *
- querypath/querypath: >=3.0.0
This package is auto-updated.
Last update: 2024-11-12 15:24:32 UTC
README
Html Parser
How to use?
public function css($content, $selector)
include('vendor/autoload.php');
PMVC\Load::plug();
$plug = \PMVC\plug('html_parser');
$object = $plug->css($html, $your_css_$selector);
var_dump($object->html());
Useful tip
text or html
- object->text()
- object->html()
get tag attribute
- object->attr('href')
Process a list (QueryPath)
- https://web.archive.org/web/20120504094800/http://api.querypath.org/docs/class_query_path.html
- Get one index
$DOMElement = QueryPath->get(int index) // start from zero
\PMVC\plug('html_parser')->css($DOMElement, $selector);
Parse Engine
- Old Api(better):
- https://github.com/technosophos/querypath
Install with Composer
1. Download composer
- mkdir test_folder
- curl -sS https://getcomposer.org/installer | php
2. Install Use composer.json or use command-line directly
2.1 Install Use composer.json
- vim composer.json
{
"require": {
"pmvc-plugin/html_parser": "dev-master"
}
}
- php composer.phar install
2.2 Or use composer command-line
- php composer.phar require pmvc-plugin/html_parser
or
- composer require pmvc-plugin/html_parser