介绍
php:7.4(作者使用的php版本)
这个脚本可以遍历从所有域名,并且访问获取标签
代码
1.获取字符排列数组
$chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-');
这里的-也是要排列的对象
2.获取域名数组
$host = array(".com", ".net", ".cn", ".org", ".ac", ".zj", ".yn", ".xz", ".xj", ".tw", ".tj", ".sx", ".sn", ".sh", ".sd", ".sc", ".qh", ".nx", ".nm", ".mo", ".ln", ".jx", ".js", ".jl", ".hn", ".hk", ".hl", ".hi", ".he", ".hb", ".ha", ".gx", ".gz", ".gs", ".fj", ".cq", ".bj", ".gd", ".ah", ".top", ".xyz", ".work", ".vip", ".email", ".club", ".site", ".live", ".wang", ".online", ".tech", ".cc", ".fans", ".group", ".host", ".cloud", ".shop", ".team", ".beer", ".ren", ".technology", ".fashion", ".luxe", ".yoga", ".red", ".love", ".ltd", ".chat", ".pub", ".run", ".city", ".kim", ".pet", ".space", ".fun", ".store", ".pink", ".ski", ".design", ".ink", ".wiki", ".video", ".company", ".plus", ".center", ".cool", ".fund", ".gold", ".guru", ".life", ".show", ".today", ".world", ".zone", ".social", ".bio", ".black", ".blue", ".green", ".lotto", ".organic", ".poker", ".promo", ".vote", ".archi", ".voto", ".fit", ".website", ".press", ".icu", ".art", ".law", ".band", ".media", ".cab", ".cash", ".cafe", ".games", ".link", ".info", ".pro", ".mobi", ".asia", ".studio", ".biz", ".vin", ".news", ".fyi", ".tax", ".tv", ".market", ".shopping", ".mba", ".sale");
3.进行遍历
function NextValue($value, $array) { $valueArray = array_reverse(str_split($value)); $charLength = count($array) - 1; $chatNumber = array(); $iTemp = 0; foreach ($array as $temp) { $chatNumber[$temp] = $iTemp; $iTemp++; } $i = 0; $add = false; foreach ($valueArray as $temp) { if ($add == true) { if ($temp == $array[$charLength]) { $valueArray[$i] = $array[0]; $i++; continue; } $valueArray[$i] = $array[$chatNumber[$temp] + 1]; //var_dump($valueArray); break; } if ($temp == $array[$charLength]) { $add = true; $valueArray[$i] = $array[0]; $i++; continue; } $valueArray[$i] = $array[$chatNumber[$temp] + 1]; break; } $result = ""; $valueArray = array_reverse($valueArray); foreach ($valueArray as $temp) { $result .= $temp; } return $result; }
为了防止内存溢出,这里采用了类似于数字进位的方法,这里展示主要函数
4.进行访问,获取域名
function get_page_title($url, $max_redirects = 3, $doc = null) { if (!is_int($max_redirects) || $max_redirects < 0) { return null; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects); curl_setopt($ch, CURLOPT_RANGE, '0-1,024,000,000'); $content = curl_exec($ch); if (curl_errno($ch)) { curl_close($ch); return null; } $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $redirect_url = curl_getinfo($ch, CURLINFO_REDIRECT_URL); curl_close($ch); if ($status_code != 200) { return null; } if ($redirect_url) { if (!$doc) { $doc = new DOMDocument(); libxml_use_internal_errors(true); @$doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); libxml_clear_errors(); } return get_page_title($redirect_url, $max_redirects - 1, $doc); } if (!$doc) { $doc = new DOMDocument(); libxml_use_internal_errors(true); @$doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); libxml_clear_errors(); } $title = 'NO TITLE'; $titles = $doc->getElementsByTagName("title"); if ($titles->length > 0) { $title = $titles->item(0)->nodeValue; } unset($doc); return $title; }
这个访问函数限制了获取页面的大小,并且可以获取页面标题
结尾
这里简单展示了基础脚本算法,但是你也可以直接下载源码,收费2元(毕竟作者要吃饭^_^),求支持一下
执行脚本后会生成一个phpsite.txt文件
执行命令:php search.php
最新评论