PHP code example of fiv / parser

1. Go to this page and download the library: Download fiv/parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fiv / parser example snippets



 $grabber = new \Fiv\Parser\Grabber();
 $links = $grabber->getHtml('http://funivan.com')->attribute('//a/@href')->getItems();
 
 print_r($links);
 


 $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;
  


  $request = new \Fiv\Parser\Request();
  $request->get('http://funivan.com');
  $httpCode = $request->getInfo()->getHttpCode();
  echo $httpCode;



  $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/");