发新话题
打印

批量反查IP上域名的beian信息程序源代码

批量反查IP上域名的beian信息程序源代码

程序要求:
PHP with iconv
复制内容到剪贴板
代码:
<?php
error_reporting(1);
if ( !$_REQUEST['ips'] )
{
        echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="robots" content="index,follow">
<meta name="title" content="自动检查beian信息">
<meta name="Generator" content="Bendy">
<title>自动检查beian信息系统 BETA 0.1 Bendy</title>
</head>

<body>
<form action="'.$_SERVER["PHP_SELF"].'" method=post>
<table width=98% align=center cellspacing=1 cellpadding=3 class=i_table>

<tr class=b>
  <td width=30% valign=top>请输入需要检查的IP 格式如(123.123.123.123-234)</td></tr><tr>
<td><input type="textbox" name="ips" size=16><input name="submit" type=submit value="开始"></td></tr>

</table>
</form>
</body>
</html>
';
exit( );
}


set_time_limit(0);
$ip_str=$_REQUEST['ips'];
$log_name="ba/".str_replace(".","_",$ip_str).".txt";
$start_ip=str_replace(strstr($ip_str,"-"),"",$ip_str);
$ips=explode(".",$start_ip);
$start=$ips[3];
$end=str_replace("-","",strstr($ip_str,"-"));
if ( !ip2long($start_ip) or !is_numeric($end) or $end > 255 or $end < $start) exit ("input wrong .please use 123.123.123-234 type") ;
$ip_str=$ips[0].".".$ips[1].".".$ips[2].".";
echo "IP地址 | 域名 | 网站名称 | 最新IP | PR值 | 百度收藏 | beian用户 | beian号 <BR>\r\n";
for($ipa=$start;$ipa <= $end; $ipa++)
{
        $ip=$ip_str.$ipa;
        $ip_url="http://ip.wen.la/?q=".$ip;
        $page=file_get_contents($ip_url);
        $w=info($page);
        $fo=fopen($log_name,"a");
        fwrite($fo,$w);
        fclose($fo);
}
echo "<BR>\r\n<a href='$log_name'>$log_name 下载</a>";

function info($page){
        $page=cut($page,"<table class='mt bot-nav'><tr><th colspan='2'>",".</table><br/>");
        $ip_address=cut($page,"</td><td>","</td><tr>");
        $page1=cut($page,"</th>","google_ad_client");
        $page2=cut($page,"google_ad_client","<td colspan='10'>");
        $tl=explode("tr onMouseOver",$page1);
        $domains=array();
        $out="";
        for ($n=1;$n<count($tl);$n++){
                $ereg="/<td>(.*)<td>(.*)<\/td><td>(.*)<td>(.*)<\/td>(.*)<\/td><td>(.*)<td>(.*)</";
                if (!preg_match($ereg,$tl[$n],$match)) continue;
                $domain=cut($match[2],'//','/ target=_blank');
                $name=iconv("UTF-8","GBK",str_replace("|"," ",$match[3]));
                $pr=cut($match[4],"images/",".gif");
                $hot=strip_tags($match[5]);
                $user=iconv("UTF-8","GBK",strip_tags($match[6]));
                $beian=iconv("UTF-8","GBK",strip_tags($match[7]));
                $ip_r=gethostbyname($domain);
                $domains[]=str_replace("www.","",$domain);
                $line="$ip_address|$domain|$name|$ip_r|$pr|$hot|$user|$beian\r\n";
                $out.=$line;
                echo "$ip_address | $domain | $name | $ip_r | $pr | $hot | $user | $beian <BR>\r\n";
                ob_flush();flush();
                //echo $line;exit;               
        }
        //part1 finished
        $t2=explode("tr onMouseOver",$page2);
        for ($n=1;$n<count($t2);$n++){
                $ereg="/<td>(.*)<td>(.*)<\/td><td>(.*)<td>(.*)<\/td>(.*)<\/td></";
                if (!preg_match($ereg,$t2[$n],$match)) continue;
                $domain=cut($match[2],'//','/ target=_blank');
                $name=iconv("UTF-8","GBK",str_replace("|"," ",$match[3]));
                $pr=cut($match[4],"images/",".gif");
                $hot=strip_tags($match[5]);
                $ip_r=gethostbyname($domain);
                $s_domain=substr($domain,strpos($domain,".")+1);
                if (in_array($domain,$domains) or in_array($s_domain,$domains)) continue;
                if ($s_domain == "com" or $s_domain == "cn" or $s_domain == "com.cn" or $s_domain == "net" or $s_domain == "net.cn" or $s_domain == "org" or $s_domain == "org.cn"  ) $s_domain=$domain;
                $temp=explode("@",get($s_domain));
                $domains[]=$s_domain;
                $user=$temp[0];
                $beian=$temp[1];
                $line="$ip_address|$domain|$name|$ip_r|$pr|$hot|$user|$beian\r\n";
                $out.=$line;               
                echo "$ip_address | $domain | $name | $ip_r | $pr | $hot | $user | $beian <BR>\r\n";
                ob_flush();flush();
        }
        return $out;        
}
function cut($haystack,$start,$end) {
    if (strpos($haystack,$start) === false || strpos($haystack,$end) === false) {
        return false;
    } else {
        $start_position = strpos($haystack,$start)+strlen($start);
        $end_position = strpos($haystack,$end);
        return substr($haystack,$start_position,$end_position-$start_position);
    }
}
function get($domain){
        //return "@null";查询beian信息
        $url="http://211.94.161.70/baxx_ggcx_servlet?cxfs=1&ym=".$domain;
        $page=file_get_contents($url);
        $info=cut($page,"<tr bgcolor=\"#FFFFFF",'updateid');
        if ($info == "") return "@null";
        $info=str_replace("\r\n","",$info);
        $ereg="/<td(.*)<\/td>(.*)<\/td>(.*)<\/td>(.*)<\/td>(.*)<\/td>/";
        if(!preg_match($ereg,$info,$match)) return "null";
        $name=trim(strip_tags($match[2]));
        $beian=trim(strip_tags($match[3]));
        $yes=trim(strip_tags($match[5]));
        if ($beian <> "") return "$name@$beian";
        return "$name@$yes";
}

?>

TOP

发新话题
最近访问的版块