suchen
Heimphp教程PHP源码PHP验证HTTP代理可用性[支持批量]

这个程序主要用来验证HTTP代理的可用性,支持单个验证,以及批量验证。 


程序写的也很简单,用来学习还是很不错的。 

项目说明: 
==============================================================================
1. 程序入口页tools.php    直接访问index.php也可以[程序会跳转] 
2. HTTP代理验证[URL采集模式]   如果里面的代理很多的话不推荐使用, 验证时间会很长 
3. 单个代理验证请使用 HTTP代理验证[SINGLE模式] 
4. 批量验证请使用 HTTP代理验证[固定格式批量验证]  固定格式如下: 

    221.130.18.125:80@HTTP;江苏省南京市 移动 
    221.130.18.126:80@HTTP;江苏省南京市 移动 
    221.130.18.127:80@HTTP;江苏省南京市 移动 

    以上代理的内容每条占一行, 分号后面的内容可以没有 也就是说必须 保证这种格式: 221.130.18.125:80@HTTP; 
5. 此代理验证工具只支持HTTP代理的验证, 不支持SOCKS代理验证. 
6. 如果改编SOCKS代理的验证, 您只需要修改 class/class.proxy.php 核心文件即可, CURL模式里面自己修改下. 
7. config.php配置文件说明 

<?php 
$config = array( 
    &#39;verify_url&#39;        =>        &#39;http://www.baidu.com/robots.txt&#39;,    //用来验证代理的URL 
    &#39;timeout&#39;        =>        20,                    //用来验证代理的时间 
    &#39;retry&#39;            =>        2,                    //如果验证失败, 重试的次数 
    &#39;root_path&#39;        =>        dirname(__FILE__), 
    &#39;host&#39;            =>        &#39;http://&#39;.$_SERVER[&#39;HTTP_HOST&#39;] 
); 
?>

1.

PHP验证HTTP代理可用性[支持批量]proxy.zip

2. [文件]     class.proxy.php

<?php
class proxy {
	private $proxy_ip;
	private $proxy_port;
	private $check_url;
	private $time_out;
	private $retry;
	
	public function __construct( $proxy_ip, $proxy_port, $check_url = &#39;http://www.baidu.com/robots.txt&#39;, $time_out = 30, $retry = 2) {
		$this -> proxy_ip = $proxy_ip;
		$this -> proxy_port = $proxy_port;
		$this -> check_url = $check_url;
		$this -> time_out = $time_out;
		$this -> retry = $retry;
	}
	
	public function check_proxy() {
		// 创建一个新cURL资源
		$ch = curl_init();
		// 设置URL和相应的选项
		curl_setopt($ch, CURLOPT_URL, $this -> check_url);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this -> time_out);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_PROXY, $this -> proxy_ip.&#39;:&#39;.$this -> proxy_port);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
		// 抓取URL并把它传递给浏览器
		$i = 1;
		$result = false;
		while($i <= $this -> retry) {
			$result = curl_exec($ch);
			if( $result !== false && substr_count($result, &#39;User-agent: Baiduspider&#39;) >=1 ) {
				$result = true;
				break;
			} else {
				$result = false;
			}
			++$i;
		}
		
		// 关闭cURL资源,并且释放系统资源
		curl_close($ch);
		//成功返回boolean true, 失败返回boolean false
		return $result;
	}
}
?>

3. [图片] UI界面.png    

           


PHP验证HTTP代理可用性[支持批量]

                                           

Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. So reparieren Sie Audio, wenn Sie niemanden hören können
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Wie man alles in Myrise freischaltet
4 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

MantisBT

MantisBT

Mantis ist ein einfach zu implementierendes webbasiertes Tool zur Fehlerverfolgung, das die Fehlerverfolgung von Produkten unterstützen soll. Es erfordert PHP, MySQL und einen Webserver. Schauen Sie sich unsere Demo- und Hosting-Services an.

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

MinGW – Minimalistisches GNU für Windows

MinGW – Minimalistisches GNU für Windows

Dieses Projekt wird derzeit auf osdn.net/projects/mingw migriert. Sie können uns dort weiterhin folgen. MinGW: Eine native Windows-Portierung der GNU Compiler Collection (GCC), frei verteilbare Importbibliotheken und Header-Dateien zum Erstellen nativer Windows-Anwendungen, einschließlich Erweiterungen der MSVC-Laufzeit zur Unterstützung der C99-Funktionalität. Die gesamte MinGW-Software kann auf 64-Bit-Windows-Plattformen ausgeführt werden.

PHPStorm Mac-Version

PHPStorm Mac-Version

Das neueste (2018.2.1) professionelle, integrierte PHP-Entwicklungstool

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen