承接 ahmard/queliwrap 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ahmard/queliwrap

Composer 安装命令:

composer require ahmard/queliwrap

包简介

QueryList PHP web scrapper wrapper.

README 文档

README

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

Notice: Queliwrap\Wrapper\Queliwrap::exec() method has been replaced with execute(). exec() now returns psr-7 compliant object while execute() returns QueryList object.

Installation

Make sure you have Composer installed.

composer require ahmard/queliwrap

After installation is done, require Composer's autoloader in your code:

require 'vendor/autoload.php';

Usage

Queliwrap relies on Guzwrap, you might want to dig a little deeper in to it.

use Queliwrap\Client;

Client::get('https://google.com')->execute()
    ->find('ul')->eq(0)
    ->find('li');

Handle errors

use Queliwrap\Client;

try {
    $text = Client::get('https://google.com')->execute()
        ->find('ul')->eq(0)
        ->find('li')
        ->text();
        
    echo $text;
}catch (Throwable $exception){
    echo $exception->getMessage();
}

Submit Form

use Guzwrap\Wrapper\Form;
use Queliwrap\Client;

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

Cookies

Thanks to Guzwrap cookies can be preserved across multiple requests

use Guzwrap\Wrapper\Form;
use Queliwrap\Client;

//Login
Client::create()
    ->referer('http://localhost:8000')
    ->withSharedCookie()
    ->form(function (Form $form){
        $form->action('http://localhost:8000/login');
        $form->method('POST');
        $form->input('email', 'queliwrap@example.com');
        $form->input('password', 1234);
        $form->input('remember_me', 1);
    })->exec();

//View user profile
$queryList = Client::create()
    ->get('http://localhost:8000/users/view')
    ->query(['id' => 2])
    ->withSharedCookie()
    ->execute();

//Find user info
$firstName = $queryList->find('.profile')
    ->find('list-group-item')
    ->eq(0)
    ->text();

echo "First name: {$firstName}";

Documentations

Licence

Queliwrap is MIT licenced.

统计信息

  • 总下载量: 159
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固