fizzka / extractor
HTML Parser
Installs: 4 868
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 2
Requires
- php: >=5.2
Requires (Dev)
README
html extraction library, based on SimpleXML & nokogiri XpathSubquery.php
Benefits
- Simple
- Minimal code
- Fast
- Query results are
SimpleXMLElement
instances - Supports nested css/xpath queries
Installation
#Using packagist: composer require 'fizzka/extractor'
Basic Usage
<?php require_once 'vendor/autoload.php'; $html = gzdecode(file_get_contents('http://habrahabr.ru/')); $ex = Extractor::fromHtml($html); var_dump($ex->get('a.habracut'));
Advanced Usage
echo $ex->cssPathFirst('div.post')->xpathFirst('.//@href'); foreach ($ex->cssPath('div.post') as $post) { var_dump($post->cssPathFirst('a.post_title')); }
Testing
Just run phpunit
from the top of project
Contribute
Feel free to use & contribute ;)
License
MIT