針對 https://www.cnproxy.com/proxy{1-10}.html 頁面結構,解析表格中經 JavaScript 混淆的 Port 號(字元對應表),提取 IP:Port 並儲存至文字檔。含分頁自動翻頁、解碼邏輯、檔案追加寫入。
<?php
class CnProxyCrawler {
public $savePath = 'proxy.txt';
private $charMap = ['z'=>3,'m'=>4,'k'=>2,'l'=>9,'d'=>0,'x'=>5,'i'=>7,'w'=>6,'q'=>8,'b'=>1];
public function fetchPage(int $page): string {
$url = 'https://www.cnproxy.com/proxy' . $page . '.html';
return file_get_contents($url);
}
public function parse(string $html): array {
// 正規表示式對應混淆 port 寫法:
$pattern = '/([\d.]+)
- 上一篇文章: PHP 分頁功能模組完整實作教學
- 下一篇文章: PHP 處理 Postfix 郵件管道內容完整指南
Copyright © 程式碼之家 All Rights Reserved