php教程 baidu 收錄查詢程序
*/
header('content-type: text/html; charset=utf-8');
require('function.php');$url = strtolower(trim($_get['url']));
$lm = intval($_get['lm']);
$pn = intval($_get['pn']);$url = getshorturl($url);
if (empty($pn)) $pn = 1;
switch ($lm) {
case 1 :
$timestr = '24小時';
break;
case 7 :
$timestr = '一星期';
break;
case 30 :
$timestr = '一個月';
break;
case 360 :
$timestr = '一年';
break;
default :
$timestr = '所有時間';
break;
}
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
if (empty($url)) {
?>
<title>35dir百度近日收錄查詢-35分類目錄</title>
<meta name="keywords" content="百度近日收錄查詢" />
<meta name="description" content="百度近日收錄查詢可按指定時間段(最近24小時、一星期、一個月、一年、所有時間)查詢,讓你及時了解網站在某一時間段內的收錄情況。" />
<?php
} else {
?>
<title><?php echo $url;?>百度最近<?php echo $timestr; ?>收錄詳情-35分類目錄</title>
<meta name="keywords" content="<?php echo $url; ?>,百度近日收錄查詢" />
<meta name="description" content="<?php echo $url; ?>,百度最近<?php echo $timestr; ?>收錄查詢結果。" />
<?php
}
?>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="copyright" content="powered by bKjia.c0m" />
<meta http-equiv="pragma" content="no-cache" />
<script type="text/網頁特效" src="jquery.js"></script>
<script type="text/jscript">
function checkfrm() {
if ($("#url").attr("value") == "") {
alert("請輸入要查詢的域名!");
$("#url").focus();
return false;
} else {
var reexp = /^([a-z0-9-]{1,}.)?[a-z0-9-]{2,}.([a-z0-9-]{1,}.)?[a-z0-9]{2,}$/i;
if (!reexp.test($("#url").attr("value"))) {
alert("請輸入正確的域名!");
$("#url").focus();
return false;
}
}
return true;
}
</script>
<link href="skin/style.css教程" rel="stylesheet" type="text/css" />
</head><body>
<div id="topbar">網站導航:<a href="http://www.bKjia.c0m/" target="_blank">35分類目錄</a> | <a href="http://www.opdir.cn/" target="_blank">open directory</a></div>
<div id="container">
<div id="header">
<a class="logo" href="http://tool.bKjia.c0m/baidu/" title="35dir百度近日收錄查詢"></a>
<div id="search">
<form name="myso" method="get" action="" onsubmit="return checkfrm();">
<span style="font: bold 16px normal;">http://</span> <input name="url" id="url" type="text" size="50" class="sipt" value="<?php echo $url;?>" />
<input type="hidden" name="lm" value="1" />
<input type="submit" class="sbtn" value="查 詢" />
<div class="tips教程">示例:<a href="javascript: void(0);" onclick="$('#url').attr('value', 'bKjia.c0m')">bKjia.c0m</a>,<a href="javascript: void(0);" onclick="$('#url').attr('value', 'www.bKjia.c0m')">www.bKjia.c0m</a>,帶"www"與不帶"www"的查詢結果不同</div>
</form>
</div>
</div>
<?php
if (!empty($url)) {
?>
<div class="tool"><strong>按時間段查詢:</strong> <a href="">最近24小時</a> <a href="">最近一星期</a> <a href="">最近一個月</a> <a href="">最近一年</a> <a href="">總收錄量</a></div>
<div id="mainer">
<?php
$query_url = 'http://www.baidu.com/s?wd=site%3a'.$url.'&pn='.$pn.'&lm='.$lm;
$line_arr = @file($query_url);
$content = implode('###', $line_arr);
$content = @mb_convert_encoding($content, 'utf-8', 'gb2312');
//index
if (preg_match('/找到相關網頁(.*?)篇/i', $content, $index)) {
$baiduindex = str_replace('約', '', $index[1]);
} else {
$baiduindex = '-';
}
?>
<div class="content">
<h2>百度在最近 <font color="#ff6600"><?php echo $timestr; ?></font> 內共收錄了網站( <a href="<?php echo getfullurl($url); ?>" target="_blank"><?php echo $url; ?></a> ) <font color="#ff6600"><?php echo $baiduindex; ?></font> 個頁面</h2>
<div>
<?php
$content = strstr($content, '<table cellpadding="0" cellspacing="0" class="result"');
$end = strpos($content, '<div id="search">');
$content = substr($content, 0, $end);
$item_arr = explode('<tr><td class=f>', $content);
//showpage
if (preg_match('/<p id="page">(.*?)</div>/', $content, $page_arr)) {
$showpage = str_replace('s?wd=site%3a', '?url=', $page_arr[1]);
$showpage = str_replace('[', '', $showpage);
$showpage = str_replace(']', '', $showpage);
}
$i = 0;
$strhtml = '<ul class="sitelist">';
foreach ($item_arr as $item) {
if (preg_match('/<a onmousedown="(.*?)" href="(.*?)" target="_blank" ><font size="3">(.*?)</font></a><br><font size=-1>(.*?)<font color="#008000">(.*?)</font> - <a href="(.*?)" target="_blank" class="m">/i', $item, $siteinfo)) {
$sitename = $siteinfo[3];
$siteurl = $siteinfo[2];
$sitedesc = $siteinfo[4];
$siteltime = $siteinfo[5];
$sitecache = $siteinfo[6];
$strhtml .= '<li>';
$strhtml .= '<strong><em>'.$i.'.</em><a href="'.$siteurl.'" target="_blank">'.$sitename.'</a></strong>';
$strhtml .= '<p>'.$sitedesc.'</p>';
$strhtml .= '<address>'.$siteltime.' - <a href="'.$sitecache.'" target="_blank">百度快照</a></address>';
$strhtml .= '</li>';
}
$i++;
}
$strhtml .= '</ul>';
$strhtml .= '<div class="showpage">'.$showpage.'</div>';
echo $strhtml;
?>
</div>
</div>
</div>
<?php
}
?>
</div>
</body>
</html>function文件
<?php
function getfullurl($url) {
if ($url != "") {
$url_parts = parse_url($url);
if ($url_parts['scheme'] == "") {
$url = "http://".$url;
}
}
return $url;
}
function getshorturl($url) {
if ($url != "") {
$url_parts = parse_url($url);
if ($url_parts['host'] == "") {
$url = $url_parts['path'];
} else {
$url = $url_parts['host'];
}
}
return $url;
}
function format_number($number) {
if ($number == '') return "-";
$nlen = strlen($number);
while ($nlen > 3) {
$fnumber = ",".substr($number, $nlen - 3, 3).$fnumber;
$number = substr($number, 0, -3);
$nlen = strlen($number);
}
if ($nlen <= 3) {
$fnumber = $number.$fnumber;
}
return $fnumber;
}
?>源碼下載地址
http://down.bKjia.c0m/s/2010/1025/21415.html