arhx/proxy-checker

此包的最新版本(1.1.0)没有可用的许可信息。

PHP 包,用于检查代理状态并返回所有必要细节

1.1.0 2019-06-24 21:25 UTC

This package is auto-updated.

Last update: 2024-09-25 10:17:38 UTC


README

代理检查服务,返回与每个代理相关的所有必要信息

安装

在项目目录中输入以下命令

composer require arhx/proxy-checker

如何使用

  1. 应使用类 Arhx\ProxyChecker\ProxyChecker
  2. ProxyChecker 类中传递 $url & $config 参数
/*
*	$check_page [required]
*	$config [optional]
*/
    $check_page = 'http://myproxychecker.com/check.php';
    $config = [
        'timeout'   => 100,
        'check'     => ['get', 'post', 'cookie', 'referer', 'user_agent'],
    ];
    $checker = new ProxyChecker($check_page, $config);

/*
*	$proxy [required]
*	&$error_message [optional]
*
*/
$proxy = 'protocol://username:password@hostname:port';

$result = $checker->checkProxy($proxy, $error_message);

if($result){
    print_r($result);
}else{
    echo "Error: $error_message\n";
}

示例输出

Array
(
   [allowed] => Array
       (
           [0] => get
           [1] => post
           [2] => cookie
           [3] => referer
           [4] => user_agent
       )

   [disallowed] => Array
       (
       )

   [proxy_level] => elite
)

检查页面示例

<?php
// possible url for this file: http://myproxychecker.com/check.php
include 'vendor/autoload.php';
$checkResult = \Arhx\ProxyChecker\ProxyChecker::checkPage();
$checkResult = implode(PHP_EOL,$checkResult);
echo $checkResult;