本工具雖標題為「PR 值檢測」,但原始碼內容實為「友情鏈接批量檢測工具」(同 ID 155095)。Google PageRank 公開查詢服務已於 2016 年 4 月正式關閉,Toolbar PR 值不再更新。本文將分析原始碼中的 PR 查詢相關邏輯 (若有),並說明現代 SEO 權重指標替代方案。
提供的程式碼完整包含:
contenteditable iframe 視覺編輯器、JS 狀態機異步檢查、超時重試。my_file_get_contents() (cURL/allow_url_fopen 回退)、正則提取 <a href>、stristr 判斷目標連結是否存在。程式碼中未包含任何 PageRank 查詢邏輯 (無 Google Toolbar PR 校驗和算法、無 toolbarqueries.google.com 請求)。
供參考了解演算法歷史:
https://toolbarqueries.google.com/search?client=navclient-auto&ch={CHECKSUM}&features=Rank&q=info:{URL}ch 參數為 URL 經過特定雜湊演算法 (類似 Jenkins Hash) 產生的 64 位元整數校驗和,需在 PHP 中完整移植 C 語言邏輯 (位元運算、溢位處理)。Rank_1:1:9 (版本:標記:PR值 0-10)。PR 值已成歷史,現代 SEO 專家使用以下第三方指標評估網站權威:
| 指標 | 提供商 | 範圍 | 特點 | API 取得 |
|---|---|---|---|---|
| Domain Authority (DA) | Moz | 1-100 | 預測域名排名能力,對數制 | Mozscape API (付費) |
| Domain Rating (DR) | Ahrefs | 0-100 | 基於反鏈數量/質量,更新快 | Ahrefs API (付費) |
| Trust Flow (TF) / Citation Flow (CF) | Majestic | 0-100 | TF 評估信任度,CF 評估流行度 | Majestic API (付費) |
| Authority Score (AS) | Semrush | 0-100 | 綜合流量、反鏈、自然關鍵字 | Semrush API (付費) |
| Page Authority (PA) | Moz | 1-100 | 單頁面級別權重 | Mozscape API |
<?php
/**
* 現代化批量權重查詢服務雛形
* 需申請 Ahrefs API Key (付費訂閱)
*/
class ModernSeoMetricsChecker {
private $apiKey;
private $baseUrl = 'https://apiv2.ahrefs.com';
private $httpClient; // GuzzleHttp\Client
public function __construct($apiKey) {
$this->apiKey = $apiKey;
$this->httpClient = new \GuzzleHttp\Client([
'timeout' => 30,
'headers' => ['Accept' => 'application/json']
]);
}
/**
* 批量查詢 Domain Rating (DR) 等指標
* @param array $domains ['example.com', 'test.org']
* @return array
*/
public function batchCheckDomainRating(array $domains) {
$results = [];
// Ahrefs API 通常支援單次查詢多個目標 (視方案而定)
// 此處示意逐個查詢,實際應使用批次端點
foreach ($domains as $domain) {
try {
$response = $this->httpClient->get("{$this->baseUrl}/v2/sites/{$domain}/metrics", [
'query' => ['token' => $this->apiKey, 'fields' => 'domain_rating,refdomains,backlinks']
]);
$data = json_decode($response->getBody(), true);
$results[$domain] = [
'dr' => $data['metrics']['domain_rating'] ?? 0,
'ref_domains' => $data['metrics']['refdomains'] ?? 0,
'backlinks' => $data['metrics']['backlinks'] ?? 0,
'status' => 'success'
];
} catch (Exception $e) {
$results[$domain] = ['status' => 'error', 'message' => $e->getMessage()];
}
usleep(200000); // 0.2秒延遲,禮貌限流
}
return $results;
}
}
// 使用
$checker = new ModernSeoMetricsChecker('YOUR_AHREFS_API_KEY');
$domains = ['github.com', 'laravel.com', 'vuejs.org'];
$metrics = $checker->batchCheckDomainRating($domains);
print_r($metrics);
?>
若需維護原專案的友鏈檢測功能,建議重構為:
POST /api/link-check),回傳 JSON,支援隊列 (Redis + Worker) 非同步處理大量 URL。fetch + AbortController 控制超時,WebSocket 推送即時進度。Guzzle + cURL Multi 並發、spatie/browsershot (Headless Chrome) 處理 JS 渲染頁面。robots.txt / Crawl-Delay。原始碼雖標題錯置,但其「視覺化輸入 -> 異步批量驗證 -> 即時反饋」的交互模式在 SEO 工具開發中極具參考價值。PageRank 已成絕響,擁抱 DA/DR/TF/AS 等現代指標,配合雲端 API 與非同步架構,才能打造專業級 SEO 監控平台。