PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Ahmad Mustapha   QueryList Wrapper   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: QueryList Wrapper
Retrieve and scrape Web page using QueryList
Author: By
Last change:
Date: 3 years ago
Size: 2,093 bytes
 

Contents

Class file image Download

Queliwrap, PHP QueryList Wrapper.

Queliwrap is a wrapper that provides easy helper functions around PHP popular web scrapper, QueryList and Guzwrap.

Notice

This library is totally different from version 1. There won't be an easy solution for users upgrading from version 1 except rewritting their scripts. This happens because we chose to use Guzwrap for making requests which provides much much easier interface for sending requests, Guzwrap uses promises as its return value. Appologies.

Installation

Make sure that you have composer installed Composer.

If you don't have Composer run the below command

curl -sS https://getcomposer.org/installer | php

Now, let's install Queliwrap:

composer require ahmard/queliwrap

Now update composer libraries to match current latest releases.

composer update

After installing, require Composer's autoloader in your code:

require 'vendor/autoload.php';

Note

We use Guzwrap in the followimg examples. You might want to dig a little deeper in to it.

Usage

use Queliwrap\Client;

Client::request(function($g){
    $g->get('https://google.com');
})->then(function($ql){
    $lists = $ql->find('ul')->eq(0)
        ->find('li');
});

Handle errors using promise's otherwise method


Client::request(function($g){
    $g->get('https://google.com');
})
->then(function($ql){
    $lists = $ql->find('ul')->eq(0)
        ->find('li');
})
->otherwise(function($e){
    echo $e->getMessage();
});

Submit Form

Client::request(function($g){
    $g->post(function($req){
        $req->url('http://localhost:8080/rand/guzwrap.php');
        $req->field('name', 'Jane Doe');
        $req->file('image', 'C:\1.jpg');
    });
});

Documentations