uwebpro/scrapoxy-api

Scrapoxy Commander 的 PHP API 容器

v2.1.0 2021-02-06 15:07 UTC

This package is auto-updated.

Last update: 2024-09-14 00:18:55 UTC


README

此软件包通过简洁的接口与 scrapoxy API 进行交互

安装

$ composer require uwebpro/scrapoxy-api

使用方法

初始化如下,第一个参数是包含 scrapoxy conf.json 文件的配置

    use UWebPro\Scrapoxy\Container;
    
    $api = new Container(__DIR__ . '/conf.json');

如果您使用的是不同的 scrapoxy 主机,可以这样更改,默认为 http://127.0.0.1:8889

    use UWebPro\Scrapoxy\Container;

    $api = new Container(__DIR__ . '/conf.json', 'http://127.0.0.1:8889);

常用函数

启动和停止代理池

如果值留为 null,则将从之前设置的缩放级别恢复

    $api->start(?int $min, ?int $required, ?int $max);
    $api->stop();

缩放代理池

    $api->rescale(int $min, int $required, int $max);

列出代理实例作为对象

    $api->getInstances();

实例对象

实例对象上可用的以下属性

    public string $name;
    public string $type;
    public string $status;
    public array $address;
    public string $region;
    public bool $alive;
    public string $useragent;

以及以下方法

    $instance->remove();

删除实例的替代方法是

    $api->removeInstance($name);

Scrapoxy 配置

可以使用以下方法读取和更新 Scrapoxy 的配置

    $api->getConfig(); //returns of config array
    
    $api->updateConfig($configArray);

所有方法返回 API 响应

贡献

您可以通过以下三种方式之一进行贡献

  1. 使用 问题跟踪器 提交错误报告。
  2. 问题跟踪器 上回答问题或修复错误。
  3. 贡献新功能或更新 wiki。

您只需确保遵循 PSR 编码指南。

许可

MIT