用Java+MySQL+PHP轻松构建跨平台的搜索引擎 - 编程入门网
ysql_connect("localhost","root","mypassword");
$result = mysql_db_query("Spider","select Id,Url,Content from WebPageLocal whe
re Id>$n1 and Id<$n2");
while($mt = mysql_fetch_array($result)){
$Title = "";
$Body = "";
$mt2 = strtoupper($mt[2]);
$PosTitleL = strpos($mt2,"<TITLE>");
$PosTitleR = strpos($mt2,"</TITLE>");
$PosBody = strpos($mt2,"<BODY");
$PosHeadR = strpos($mt2,"</HEAD>");
if($PosTitleL&&$PosTitleR) $Title = substr($mt[2],$PosTitleL+7,$PosTitl
eR-$PosTitleL-7);
$Title = eregi_replace("''","’",$Title);
if($PosBody) $Body = substr($mt[2],$PosBody);
else if($PosHeadR) $Body = substr($mt[2],$PosHeadR+7);
else if($PosTitleR) $Body = substr($mt[2],$PosTitleR+8);
else if($PosTitleL) $Body = substr($mt[2],$PosTitleL);
else $Body = $mt[2];
$BodyText = strip_tags($Body);
$BodyNoSpace = eregi_replace("","",$BodyText);
$BodyNoQuote = eregi_replace("''","",$BodyNoSpace);
$Body512 = substr($BodyNoQuote,0,511)." ";
$Id = $mt[0];
$Url = $mt[1];
$sql="Insert Into WebPageFindFast(Id,Url,Title,Content)
VALUES($Id,''$Url'',''$Title'',''$Body512'')";
mysql_db_query("Spider",$sql) or die($sql);
echo $Id." ";
}
?>
使用方式: 在浏览器中输入http://mywebsite/Spider/MakeFast.php?n1=1&n2=10000 用Java+MySQL+PHP轻松构建跨平台的搜索引擎(5)时间:2010-07-19五、以上是建立搜索引擎所用到的数据,下面编制用于用户搜索的网页和PHP脚本文件。首先是用于搜索的表单页面SearchForm.htm,其内容如下。 <html> <head> <title>红蜘蛛搜索引擎-V0.1</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link rel="stylesheet" href="../All.Css" type="text/css"> </head> <body bgcolor="#eeffee" text="#000000"> <table width="600" border="0" cellspacing="2" cellpadding="2" align="center" bgc olor="#99CC00"> <tr> <td> <div align="center"><font color="#FF0000"><b><span class="pt16">红蜘蛛搜索 引擎</span> <span class="pt12">V0.1</span></b></font></div> </td> </tr> </table> <form name="form1" method="post" action="Search.php"> <table width="600" border="1" cellspacing="1" cellpadding="1" align="center" b ordercolor="#99CC00"> <tr> <td> <div align="left"><span class="pt15"><font color="#FF0000"><b>关 键 字</ b>:</font></span> <input type="text" name="KeyWords" size="40" maxlength="40"> </div> </td> <td> <div align="left"><span class="pt15"><font color="#FF0000"><b>查找范围</ b>:</font> |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |