使用代理

示例(发送一个使用代理的请求)

use XCrawler\XCrawler;

$xcrawler = new XCrawler([
    'name' => 'proxy demo',
    'requests' => function() {
        // 普通代理
        $request = [
            'uri' => $data['url'],
            'proxy' => 'tcp://localhost:8125',
        ];
        yield $request;
        // 包含用户名、密码的代理
        $request = [
            'uri' => $data['url'],
            'proxy' => 'http://username:password@192.168.16.1:10',
        ];
        yield $request;
    },
    'success' => function($result, $request) {
        // do something
    }
]);
$xcrawler->run();