PHP implements collection of China proxy server network
This article mainly introduces PHP to implement the collection of China proxy server network. Interested friends can refer to it. I hope it will be helpful to everyone.
The example in this article describes the method of collecting China's proxy server network in PHP. The details are as follows:
<?php /** * 采集中国代理服务器网 最新列表 */ class proxy { /* 需采集列表 */ public $list; /* 代理列表 保存路径 */ public $save_path = 'proxy.txt'; /* 获取采集列表 */ function get_list($page) { $url = 'http://www.cnproxy.com/proxy(*).html'; // 处理列表 $this->list = preg_replace('/\(\*\)/', $page, $url); return $this->list; } /* 采集代理内容 */ function get($page) { $this->get_list($page); $file = stripslashes(file_get_contents($this->list)); $zz = '/<tr><td>([0-9\.]+)<SCRIPT type=text\/javascript>document\.write\(":"([\+a-z]+)\)<\/SCRIPT><\/td><td>[\w]+<\/td><td>[\w\,]+<\/td>/is'; preg_match_all($zz, $file, $temp); unset($temp[0]); $th = array('z', 'm', 'k', 'l', 'd', 'x', 'i', 'w', 'q', 'b'); $th2 = array(3, 4, 2, 9, 0, 5, 7, 6, 8, 1); foreach ($temp[2] as $k=>$v) { $v = preg_replace("/[\+]+/", '', $v); $s = str_replace($th, $th2, $v); $re .= $temp[1][$k] . ':' . $s . "\r\n"; } $this->save($re); return true; } /* 保存 */ function save($re) { return file_put_contents($this->save_path, $re, FILE_APPEND); } /* 读取 */ function read() { return file_get_contents($this->save_path); } } // 初始化采集类 $p = new proxy; $start = 1; $end = 10; // 控制 if($_GET['a'] == 'start') { echo '正在发送采集请求'; echo '<meta http-equiv="Refresh" content="3;URL=?p=1">'; } elseif(isset($_GET['p'])) { $i = $_GET['p']++; if($i >= $end+1) { exit('<meta http-equiv="Refresh" content="0;URL=?a=end">'); } else { echo '正在请求列表 '. $i .' > '. $end; if($p->get($i)) { echo '<meta http-equiv="Refresh" content="3;URL=?p='.$_GET['p']++.'">'; } } } elseif($_GET['a'] == 'end') { echo '采集完毕'; } else { echo '<form> <input type="hidden" name="a" value="start" /> <input type="submit" value="开始采集" /> </form>'; } ?>
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
Related issues with PHP garbage collection mechanism
php for strings Traversal and interception operation skills
Get week information of a certain month based on PHP
The above is the detailed content of PHP implements collection of China proxy server network. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
