How php collects the Chinese proxy server network

Source: Internet
Author: User

How php collects the Chinese proxy server network

This example describes how php collects the proxy server network in China. Share it with you for your reference. The details are as follows:

<? Php/*** collect the latest list of proxy servers in China */class proxy {/* list to be collected */public $ list; /* Save the proxy list path */public $ save_path = 'proxy.txt ';/* obtain the collection list */function get_list ($ page) {$ url = 'HTTP: // www.cnproxy.com/proxy (* pai.html '; // processing list $ this-> list = preg_replace ('/\ (\ * \)/', $ page, $ url ); return $ this-> list;}/* collect proxy 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 '); $ 2nd = 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, $ YY, $ v ); $ Re. = $ temp [1] [$ k]. ':'. $ s. "\ r \ n" ;}$ this-> save ($ re); return true;}/* save */function save ($ re) {return file_put_contents ($ this-> save_path, $ re, FILE_APPEND);}/* read */function read () {return file_get_contents ($ this-> save_path );}} // initialize the collection class $ p = new proxy; $ start = 1; $ end = 10; // control if ($ _ GET ['a'] = 'start ') {echo 'sending collection 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 'request list '. $ I. '> '. $ end; if ($ p-> get ($ I) {echo '<meta http-equiv = "Refresh" content = "3; URL =? P = '. $ _ GET ['P'] ++. '">' ;}} elseif ($ _ GET ['a'] = 'end') {echo 'collection finished ';} else {echo '<form> <input type = "hidden" name = "a" value = "start"/> <input type = "submit" value = "start collection "/> </form> ';}?>

I hope this article will help you with 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.