PHP批量查询网站标题和IP地址工具 - 支持TXT网址列表
<?php
//读取存储网址的txt文本
$file = file_get_contents('urls.txt');
//将文本内容按行拆分成数组
$urls = explode('\n', $file);
//循环遍历每个网址
foreach($urls as $url){
//去除空格和换行符
$url = trim($url);
//如果网址不为空
if(!empty($url)){
//获取网址对应的IP地址
$ip = gethostbyname($url);
// 使用curl获取网站标题
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // 设置超时时间
$content = curl_exec($ch);
curl_close($ch);
// 使用正则表达式提取标题
preg_match('/<title>(.*?)</title>/', $content, $matches);
$title = isset($matches[1]) ? $matches[1] : '获取标题失败';
//输出网址、标题和IP地址
echo '网址:'.$url.'<br>';
echo '标题:'.$title.'<br>';
echo 'IP地址:'.$ip.'<br>';
echo '<hr>';
}
}
?>
原文地址: https://www.cveoy.top/t/topic/jsKu 著作权归作者所有。请勿转载和采集!