哪位高手,使用JSP如果实现如下效果?
lwwwp 2003-12-04 07:30:26 以下代码保存为.htm文件,即可在浏览中可看到效果:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.style1 {font-size: 12px}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<script language=vbscript>
'-----------------------
Function GetBytes2BSTR(p_sHtmlStr)
dim sReturnStr
dim i,n
sReturnStr = ""
n = LenB(p_sHtmlStr)
For i = 1 To n
dim sCharCode
dim sNextCharCode
sCharCode = AscB( MidB(p_sHtmlStr, i, 1) )
If (sCharCode < &H80) Then
sReturnStr = sReturnStr & Chr(sCharCode)
Else
sNextCharCode = AscB( MidB(p_sHtmlStr, i+1, 1) )
sReturnStr = sReturnStr & Chr(CLng(sCharCode) * &H100 + CInt(sNextCharCode))
i = i + 1
End If
Next
GetBytes2BSTR = sReturnStr
End Function
Function getData(strUrl)
Dim xmlhttp
Set xmlhttp=CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "get",strUrl,false
xmlhttp.send
getData=GetBytes2BSTR(xmlhttp.responseBody)
End Function
Function test()
dim Sword,page,Url,SourceCode,Setop,Scondent,SeEnd,SePage
dim tt1,tt2
dim betw,first
Url="http://www1.baidu.com/baidu?cl=3&tn=baidu&word=我爱你"
SourceCode=getData(Url)
'------------
if instr(SourceCode,"相关网页0篇")>0 then
Scondent="<br><table width=100% border=0 id=table1><tr><td vAlign=top colSpan=2 style=font-size: 9pt; line-height: 18px><font style=FONT-SIZE: 12pt>未找到相关结果,建议您:</font></td><td vAlign=top rowSpan=2 style=font-size: 9pt; line-height: 18px> </td></tr><tr><td width=100 style=font-size: 9pt; line-height: 18px> </td><td vAlign=top width=70% style=font-size: 9pt; line-height: 18px><font style=FONT-SIZE: 12pt><ol><li>检查输入文字有无错误,或换用更少的文字查询。<br><br></li><li>到<a href=http://?>搜索援助中心</a>寻求帮助,或学习<a href=jiqiao.html>搜索技巧</a>。 </li></ol></font></td></tr></table></br>"
else
betw=instr(SourceCode,"<TABLE bgColor=#e6e6e6 border=0 cellPadding=0 cellSpacing=0 width=")-instr(SourceCode,"<tr><td align=right><font class=c size=""-1"">到<a href=""http://forum.baidu.com/cgi-bin/forum/board_show.cgi?id=1&age=60"">搜索援助中心</a>")
first=instr(SourceCode,"<TABLE bgColor=#e6e6e6 border=0 cellPadding=0 cellSpacing=0 width=")
SourceCode = Mid(SourceCode,first,abs(betw))
SourceCode =replace(SourceCode,"/baidu?","search.asp?")
tt1=split(SourceCode,"<ol>")
Setop="YaoSou搜索"&Mid(tt1(0),instr(tt1(0),"为"),abs(instr(tt1(0),"为")-instr(tt1(0),"秒")))&"秒"
tt2=split(left(tt1(1),instr(tt1(1),"</ol>")+4),"<p class=p2>")
num1=ubound(tt2)
if num1=0 then
tt2=split(tt1(1),"<p class=""p2"">")
num2=ubound(tt2)
end if
if num2>0 then
num1=num2
end if
if num1<>0 then
Scondent="<br><ol>"
for i =1 to int(num1)
if instr(tt2(i),"class=c>百度快照</a>")>0 then
Scondent = Scondent&"<p class=p2>"&left(tt2(i),instr(tt2(i),"> - <a"))&replace(right(tt2(i),len(tt2(i))-instr(tt2(i),"百度快照</a>")-7),"baidu?","search.asp?")
else
if instr(tt2(i),"</table>")=0 then
Scondent = Scondent&"<p class=p2>"&replace(tt2(i),"/q="&Sword&"&off=5&url=","")
end if
end if
next
end if
SePage="<img border=0 src=images/bz.gif width=43 height=52 align=absmiddle> "&replace(replace(left(tt1(2),instr(tt1(2),"</ol>")-1),"baidu?","search.asp?"),"baidu","wrclub")
dim SD
SD=instr(SePage,"<p>")
if SD>0 then
SePage=left(SePage,SD-1)
end if
SePage="<table border='0' style='border-collapse: collapse' width='100%' cellpadding='0'><tr><td width='11'><img border='0' src='images/pageleft.gif' width='11' height='56'></td><td background='images/pagebg.jpg'><b>"&SePage&"</b></td><td background='images/pagebg2.gif' width='52'><a href='#'><img border='0' src='images/gotop.gif' width='52' height='27'></a></td><td width='13'><img border='0' src='images/pageright.gif' width='13' height='56'></td></tr></table>"
if instr(tt1(2),"<table")>0 and instr(tt1(2),"</table>")>0 then
SeEnd=replace(replace(replace(mid(tt1(2),instr(tt1(2),"<table"),instr(tt1(2),"</table>")+8-instr(tt1(2),"<table")),"baidu?","search.asp?"),"baidu","wrclub"),">>更多相关搜索...","")&"</td></tr></table>"
end if
end if
'------------------------
SetopHTML.innerHTML=Setop
ScondentHTML.innerHTML=Scondent
SeEndHTML.innerHTML=SeEnd
SePageHTML.innerHTML=SePage
'-------------
End function
</script>
</head>
<body language=vbscript onLoad=test>
<table style="BORDER-COLLAPSE: collapse" borderColor="#111111" height="181" cellSpacing="8" cellPadding="2" width="100%" border="0">
<tbody>
<tr>
<td vAlign="top" height="250" width=70%>
<p>
<div id=SetopHTML class="style1"></div>
<%//=Setop%>
<table cellspacing=10 cellpadding=0 border=0 width=100%>
<tr>
<td background=images/result_line.gif><spacer type=block height=1>
</table>
<%//=Scondent%><%//=SeEnd%>
<div id=ScondentHTML class="style1"></div>
<div id=SeEndHTML class="style1"></div>
<table cellspacing=10 cellpadding=0 border=0 width=100%>
<tr>
<td background=images/result_line.gif><spacer type=block height=1>
</table>
<div id=SePageHTML class="style1"></div>
<%//=SePage%>
</td>
<td vAlign="top" width="30%" height="250" align="right">
<table border="0" style="border-collapse: collapse" width="200" cellpadding="0" id="table4" bgcolor="#F0F0F0" height="167">
<tr>
<td height="25">
<table cellSpacing="0" cellPadding="0" width="100%" border="0" id="table5">
<tr>
<td width="26"> </td>
<td class="p6" vAlign="bottom" width="100%" background="images/index_back5.gif"> <font color="#5c5c5c"><b>推荐网站</b></font></td>
<td width="12"> </td>
</tr>
</table></td>
</tr>
<tr>
<td><!--# include file="webtj.inc"--></td>
</tr>
</table></td>
</tr>
</tbody>
</table>
</body>
</html>