fiv / parser
This package is abandoned and no longer maintained.
The author suggests using the xparse/parser package instead.
Parser bundle
2.0.3
2014-11-28 09:23 UTC
Requires
- php: >=5.4
- fiv/spl: 1.1.*
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2022-02-01 12:28:25 UTC
README
Flexible way for data scraping
Installation
composer require fiv/parser:2.0.*
Fetch all href attributes
$grabber = new \Fiv\Parser\Grabber(); $links = $grabber->getHtml('http://funivan.com')->attribute('//a/@href')->getItems(); print_r($links);
Submit form
$grabber = new \Fiv\Parser\Grabber(); $page = $grabber->getHtml('http://funivan.com/admin/'); $formData = array('name' => 'admin'); $adminPage = $grabber->submitForm($formData, '//form[@id="login"]'); $logoutLink = $adminPage->attribute('//a[@id="logout"]/@href')->getFirst(); echo $logoutLink;
Get page status
$request = new \Fiv\Parser\Request(); $request->get('http://funivan.com'); $httpCode = $request->getInfo()->getHttpCode(); echo $httpCode;
Get page and store in local cache
$request = new \Fiv\Parser\Request(); $request->setCacheAdapter(new \Fiv\Parser\Cache\FileCache()); # real request to server $page = $request->get("http://funivan.com/"); # get from cache $cachePage = $request->get("http://funivan.com/");