ahmard/reactphp-querylist

ReactPHP QueryList Scrapper

0.0.1 2021-10-05 22:19 UTC

This package is auto-updated.

Last update: 2022-05-05 23:32:04 UTC


README

This library brought ReactPHP and QueryList together.

Installation

composer require ahmard/reactphp-querylist

Usage

  • Playing with QueryList(scraping)
use ReactphpQuerylist\Client;
use ReactphpQuerylist\Queryable;

require 'vendor/autoload.php';

Client::get('https://google.com')
    ->then(function (Queryable $queryable){
        $title = $queryable->queryList()->find('head title')->text();
        var_dump($title);
    })
    ->otherwise(function ($error){
        echo $error;
    });
  • Working with response object
use ReactphpQuerylist\Client;
use ReactphpQuerylist\Queryable;

require 'vendor/autoload.php';

Client::get('https://google.com')
    ->then(function (Queryable $queryable){
        var_dump($queryable->response()->getReasonPhrase());
    })
    ->otherwise(function ($error){
        echo $error;
    });