帮你打造属于自己的搜索引擎---百度篇(2)
pn = Request.QueryString("pn")
'开始错误处理
On Error Resume Next
If Err.Number <> 0 Then
Response.Clear
'显示错误信息给用户
Response.Write "<p align='center' ><font size=3> 出错了,请重新打开百度搜索.</font></p>"
end if
%>
<HTML>
<HEAD>
<TITLE>百度搜索--<%=wd%></TITLE>
</HEAD>
<STYLE type=text/css>
<!--
body,td{font-family:arial}
TD{FONT-SIZE:9pt;LINE-HEIGHT:18px}
.cred{color:#FF0000}
//-->
</STYLE>
<BODY leftmargin="0" topmargin="3" marginwidth="0" marginheight="0">
<table align="center" width="98%" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" >
<tr>
<form name="f1" method="post" action="searchi_bd.asp">
<td width=150 height=50>
你的LOGO
</td>
<td align="left">
<input name=wd size="40" maxlength="100" title="输入关键字,然后Let's Searching..." value="<%=wd%>">
<input type="submit" value=" 百度搜索 ">
</td></form></tr>
</table>
<%
Dim strUrl,strTmp_bd,strInfo,strPage,strPageSum_bd,strQtime_bd
Dim bNoResult_bd,regEx,patrn
'百度查询字符串
strUrl = "http://www.baidu.com/s?ie=gb2312&wd="&wd&am ... &pn&"&cl=3"
'开始采集
strTmp_bd = GetHTTPPage(strUrl)
If InStr(strtmp_bd,"未找到和您的查询")<>0 Then
bNoResult_bd=1
End If
'截取"搜索结果"部分的内容
strinfo = strCut(strTmp_bd,"<DIV id=ScriptDiv></DIV>","<br clear=all>",2)
patrn="</td></tr></table><br>"
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true
regEx.Global = false
strinfo=regEx.replace(strinfo,"")
'截取"分页区"部分的内容
strPage = strCut(strTmp_bd,"<br clear=all>","<br>",2)
strPage = Replace(strPage,"href=s?","href=searchi_bd.asp?")
'结果数量与用时
strPageSum_bd=strCut(strtmp_bd,"找到相关网页约","篇",2)
if not IsNumeric(strPageSum_bd) then
strPageSum_bd=strCut(strtmp_bd,"找到相关网页","篇",2)
end if
strQtime_bd=strCut(strtmp_bd,"用时","秒",2)
Set strTmp_bd=nothing
%>
<!-- T1-Start -->
<table cellspacing=0 cellpadding=0 border=0 width=98% align="center">
<tr valign=center align=middle height=18>
内容版权声明:除非注明,否则皆为本站原创文章。