IP反查域名PHP源码_PHP教程
程序员文章站
2022-03-25 11:49:05
...
IP反查域名,现在用的一般是bing的一个IP查询功能,即IP:222.222.222.222
写成php代码就变成了
// 调用方法
$result=getResult("124.205.228.114");
print_r($result);
function getContent($url){
$content=file_get_contents($url);
return $content;
}
function getResult($ip){
$pagesize=10;
$page=1;
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$result=array();
do
{
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$content=getContent($url);
$pattern="/([a-zA-Z0-9\.]*)(?:\/.*)?/isU";
preg_match_all($pattern, $content, $matches);
$result=array_merge($result,$matches[1]);
$nextpage=strpos($content, "下一页");
$page=$page+$pagesize;
}while($nextpage);
$result=array_values(array_unique($result));
return $result;
}
?>
// 调用方法
$result=getResult("124.205.228.114");
print_r($result);
function getContent($url){
$content=file_get_contents($url);
return $content;
}
function getResult($ip){
$pagesize=10;
$page=1;
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$result=array();
do
{
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$content=getContent($url);
$pattern="/([a-zA-Z0-9\.]*)(?:\/.*)?/isU";
preg_match_all($pattern, $content, $matches);
$result=array_merge($result,$matches[1]);
$nextpage=strpos($content, "下一页");
$page=$page+$pagesize;
}while($nextpage);
$result=array_values(array_unique($result));
return $result;
}
?>
摘自 gaohui blog
写成php代码就变成了
// 调用方法
$result=getResult("124.205.228.114");
print_r($result);
function getContent($url){
$content=file_get_contents($url);
return $content;
}
function getResult($ip){
$pagesize=10;
$page=1;
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$result=array();
do
{
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$content=getContent($url);
$pattern="/([a-zA-Z0-9\.]*)(?:\/.*)?/isU";
preg_match_all($pattern, $content, $matches);
$result=array_merge($result,$matches[1]);
$nextpage=strpos($content, "下一页");
$page=$page+$pagesize;
}while($nextpage);
$result=array_values(array_unique($result));
return $result;
}
?>
// 调用方法
$result=getResult("124.205.228.114");
print_r($result);
function getContent($url){
$content=file_get_contents($url);
return $content;
}
function getResult($ip){
$pagesize=10;
$page=1;
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$result=array();
do
{
$url="http://cn.bing.com/search?q=ip%3A$ip&first=$page";
$content=getContent($url);
$pattern="/([a-zA-Z0-9\.]*)(?:\/.*)?/isU";
preg_match_all($pattern, $content, $matches);
$result=array_merge($result,$matches[1]);
$nextpage=strpos($content, "下一页");
$page=$page+$pagesize;
}while($nextpage);
$result=array_values(array_unique($result));
return $result;
}
?>
摘自 gaohui blog