uwebpro/scrapoxy-api

PHP API Container for Scrapoxy Commander

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

This package is auto-updated.

Last update: 2024-05-13 23:39:12 UTC


README

This package interacts with the API from scrapoxy via a straight-forward interface

Installing

$ composer require uwebpro/scrapoxy-api

Usage

Initialse like so, parameter one is your scrapoxy conf.json file containing

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

If you are using a different scrapoxy host that can be changed like so, by default it is http://127.0.0.1:8889

    use UWebPro\Scrapoxy\Container;

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

Common functions

To start and stop a proxy pool

if values are left as null they will resume from previously set scaling

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

To Scale your proxy pool

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

To list proxy instances as objects

    $api->getInstances();

Instance object

The following properties are available on the instance object

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

As well as the following method

    $instance->remove();

An alternative to removing instances is

    $api->removeInstance($name);

Scrapoxy config

Scrapoxy's config can be read and updated using the following methods

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

ALL METHODS RETURN API RESPONSE

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

You just need to make sure that you follow PSR coding guidelines.

License

MIT