利用 file_get_contents() 批量查詢 rank.ie.sogou.com,解析返回的 sogourank=數字,輸出 Rank > 2 的域名。
<?php
date_default_timezone_set('Asia/Shanghai');
header('Content-Type: text/html; charset=utf-8');
$txt = @file_get_contents("list.txt");
$arr = explode("\r\n", trim($txt));
if (count($arr) < 1) exit('no site');
foreach ($arr as $domain) {
$domain = trim($domain);
if (!$domain) continue;
$url = "https://rank.ie.sogou.com/sogourank.php?ur=http%3A%2F%2F{$domain}%2F";
$sr = @file_get_contents($url);
$sr = str_replace('sogourank=', '', $sr);
$rank = intval($sr);
if ($rank > 2) {
echo $domain . "
\n";
}
}
?>
注意:大量查詢請加入延時或使用多線程,避免被目標站點封禁 IP。