Skip to content
Deprecated. xparse/Parser
PHP Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Fiv/Parser
tests
.gitattributes
.gitignore
.travis.yml
README.md
composer.json
composer.lock

README.md

Fiv/Parser

Flexible way for data scraping

Build Status GitHub version

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/");
  
You can’t perform that action at this time.