The method of collecting Chinese proxy server network in PHP

Source: Internet
Author: User
Tags php programming

This article illustrates the method of PHP collecting Chinese proxy server network. Share to everyone for your reference. Specifically as follows:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 <?php/** * Collection of the latest list of China Proxy Server network */class Proxy {/* need to collect list/public $list;/* Proxy list save path * * Public $save _path = ' proxy.txt '; /* Get capture list/function Get_list ($page) {$url = ' http://www.cnproxy.com/proxy (*). html ';//Process list $this->list = Preg_repla CE ('/(*)/', $page, $url); return $this->list; /* Collection Agent content/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 '); $th 2 = 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, $th 2, $v); $re. = $temp [1][$k ] . ':' . $s. "RN"; $this->save ($re); return true; } * * Save/Function Save ($re) {return file_put_contents ($this->save_path, $re, File_append)}/* Read/function reads () {return file_get_contents ( $this->save_path); }//Initialization collection Class $p = new Proxy; $start = 1; $end = 10; Control if ($_get[' a '] = = ' start ') {echo ' is sending acquisition request '; 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 ' is requesting list '. $i. ' > '. $end; if ($p->get ($i)) {echo ' <meta http-equiv= ' Refresh ' content= ' 3; url=?p= '. $_get[' P ']++. ' > '; }} elseif ($_get[' a '] = = ' End ') {echo ' collected ';} else {echo ' <form> <input type= ' hidden ' name= ' a ' value= ' start "/> <input type=" Submit "value=" began to collect "/> </form>"; }?>

I hope this article will help you with your PHP programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.