2017 © Pedro Peláez
 

library parser

Parser client

image

xparse/parser

Parser client

  • Wednesday, April 18, 2018
  • by funivan
  • Repository
  • 2 Watchers
  • 1 Stars
  • 8,270 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 3 Open issues
  • 15 Versions
  • 9 % Grown

The README.md

Parser

GitHub tag Software License Coverage Status Quality Score Total Downloads, (*1)

Parser client, (*2)

Install

Via Composer, (*3)

``` bash $ composer require xparse/parser, (*4)


## Usage ``` php $parser = new \Xparse\Parser\Parser(); $title = $parser->get('http://funivan.com')->content('//*[@class="entry-title"]/a'); print_r($title);

Using with custom Middleware

If you are using custom Guzzle Middleware and it doesn't send real requests, in order to get last effective url you need to set it to response X-GUZZLE-EFFECTIVE-URL header manually., (*5)

Here is an example of __invoke() method in your custom Middleware, (*6)

``` php public function __invoke(callable $handler) : \Closure { return function (RequestInterface $request, array $options) use ($handler) {, (*7)

  # some code

  return $handler($request, $options)->then(function (ResponseInterface $response) use ($request) {

    $response = $response->withHeader('X-GUZZLE-EFFECTIVE-URL', $request->getUri());

    # some code

    return $response;
  });
};

}, (*8)


# Recursive Parser Recursive Parser allows you to parse website pages recursively. You need to pass link from where to start and set next page expression (xPath, css, etc). ## Basic Usage Try to find all links to the repositories on github. Our query will be `xparse`. With recursive pagination we can traverse all pagination links and process each resulting page to fetch repositories links. ```php use Xparse\Parser\Parser; use Xparse\Parser\RecursiveParser; # init Parser $parser = new Parser(); # set expression to pagination links and initial page url $pages = new RecursiveParser( $parser, ["//*[@class='pagination']//a/@href"], ['https://github.com/search?q=xparse'] ); $allLinks = []; foreach($pages as $page){ # set expression to fetch repository links $adsList = $page->value("//*[@class='repo-list-name']//a/@href")->all(); # merge and remove duplicates $allLinks = array_values(array_unique(array_merge($allLinks, $adsList))); } print_r($allLinks);

Testing

bash ./vendor/bin/phpunit, (*9)

Contributing

Please see CONTRIBUTING for details., (*10)

Credits

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

18/04 2018

dev-master

9999999-dev https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

18/04 2018

0.3.0

0.3.0.0 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

28/01 2018

0.2.4

0.2.4.0 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

06/11 2017

0.2.3

0.2.3.0 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

07/09 2017

0.2.2

0.2.2.0 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

05/09 2017

0.2.1

0.2.1.0 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

05/09 2017

0.2.0

0.2.0.0 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

12/07 2016

0.1.0-alpha.4

0.1.0.0-alpha4 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

02/06 2016

0.1.0-alpha.3

0.1.0.0-alpha3 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

25/05 2016

0.1.0-alpha.2

0.1.0.0-alpha2 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

21/04 2016

0.1.0-alpha.1

0.1.0.0-alpha1 https://github.com/xparse/Parser

Parser client

  Sources   Download

MIT

The Requires

 

The Development Requires

parser grabber

21/04 2016
29/07 2015
09/07 2015
26/12 2014