科技知識動態:采集中國代理服務器網

導讀跟大家講解下有關采集中國代理服務器網,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說采集中國代理服務器網,小編也收集到

跟大家講解下有關采集中國代理服務器網,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說采集中國代理服務器網,小編也收集到了有關采集中國代理服務器網的相關資料,希望大家看到了會喜歡。

php代碼

<?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>';}?>

來源:php中文網

免責聲明:本文由用戶上傳,如有侵權請聯系刪除!