上次写的金牌榜的源代码:
//Powered By Allinhands.QQ:1707477.E-mail:Allinhands@21cn.com
<%
'乾坤大挪移
function getPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.setrequestHeader "Accept-Language","zh-cn"
Http.setRequestHeader "content-type","application/x-www-form-urlencoded"
Http.send()
if Http.readystate<>4 then
exit function
end if
getPage=Bytes2bStr(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function
Function Bytes2bStr(vin)
Dim BytesStream,StringReturn
Set BytesStream = Server.CreateObject("ADODB.Stream")
With BytesStream
.Open
.WriteText vin
.Position = 0
.Charset = "GB2312"
.Position = 2
StringReturn = .ReadText
.close
End With
Set BytesStream = Nothing
Bytes2bStr = StringReturn
End Function
Function GetStr(HTML,shtml,ehtml)
dim StartPos,EndPos,Length
if instr(1,HTML,shtml) then
StartPos=Instr(1,HTML,shtml)+len(shtml)
else
StartPos=1
end if
if instr(StartPos,HTML,ehtml) then
EndPos=Instr(StartPos,HTML,ehtml)
else
EndPos=len(HTML)+1
end if
Length=EndPos-StartPos
GetStr=Mid(HTML,StartPos,Length)
End Function
function RegExpTest(patrn, strng)
Dim regEx,Match,Matches,RetStr
Set regEx = New RegExp
regEx.Pattern= patrn
regEx.IgnoreCase = True
regEx.Global=True
set Matches=regEx.Execute(strng)
for each Match in Matches
RetStr=RetStr&Match.SubMatches(0)&","
Next
RegExpTest=RetStr
end function
%>
<%
vColor=Request.QueryString("color")
vSize=Request.QueryString("size")
vMode=Request.QueryString("mode")
Response.Write("<!--"&vColor&"-->")
if vColor="" then
vColor="#FF9900"
end if
if vSize="" then
vSize="12"
end if
if vMode="" then
vMode="n"
end if
HTML=getPage("http://2004.163.com/special/j/jpb.html")
HTML=GetStr(HTML,">总</td>","<!!piecename=""中国夺牌历程回顾"">")
Table=Split(HTML,"</table>")(0)
Country=Split(Table,"</tr>")
for i = 0 to UBound(Country)
if Instr(Country(i),"中国")>0 then
C_China=Country(i)
Order=i
exit for
end if
next
Num=SPlit(REgExpTest(">(\d+)<",C_China),",")
Gold=Num(1)
Silver=Num(2)
Copper=Num(3)
%>
var outstr="";
<%
Response.write("var Gold="&Gold&";"&vbcrlf)
Response.write("var Silver="&Silver&";"&vbcrlf)
Response.write("var Copper="&Copper&";"&vbcrlf)
Response.write("var Order="&Order&";"&vbcrlf)
if vMode="n" then
%>
outstr+="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" align=\"center\">";
outstr+=" <tr>";
outstr+=" <td colspan=\"8\"><img src=\"http://www.mofao.com/images/2004_r1_c1.jpg\" width=\"600\" height=\"59\" ></td>";
outstr+=" </tr>";
outstr+=" <tr>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_r2_c1.jpg\" width=\"259\" height=\"41\" ></td>";
outstr+=" <td width=\"29\" background=\"http://www.mofao.com/images/2004_r2_c2.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Order+"</td>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_r2_c3.jpg\" width=\"65\" height=\"41\" ></td>";
outstr+=" <td width=\"33\" background=\"http://www.mofao.com/images/2004_r2_c4.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Gold+"</td>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_r2_c5.jpg\" width=\"70\" height=\"41\" ></td>";
outstr+=" <td width=\"35\" background=\"http://www.mofao.com/images/2004_r2_c6.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Silver+"</td>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_r2_c7.jpg\" width=\"65\" height=\"41\" ></td>";
outstr+=" <td width=\"44\" background=\"http://www.mofao.com/images/2004_r2_c8.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Copper+"</td>";
outstr+=" </tr>";
outstr+="</table>";
<%
elseif vMode="s" then
%>
outstr+="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"211\">";
outstr+=" <tr>";
outstr+=" <td rowspan=\"4\"><img src=\"http://www.mofao.com/images/2004_s_r1_c1.jpg\" width=\"114\" height=\"100\" ></td>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_s_r1_c2.jpg\" width=\"59\" height=\"28\" ></td>";
outstr+=" <td width=\"38\" background=\"http://www.mofao.com/images/2004_s_r1_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Order+"</td>";
outstr+=" </tr>";
outstr+=" <tr>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_s_r2_c2.jpg\" width=\"59\" height=\"22\" ></td>";
outstr+=" <td background=\"http://www.mofao.com/images/2004_s_r2_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Gold+"</td>";
outstr+=" </tr>";
outstr+=" <tr>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_s_r3_c2.jpg\" width=\"59\" height=\"22\" ></td>";
outstr+=" <td background=\"http://www.mofao.com/images/2004_s_r3_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Silver+"</td>";
outstr+=" </tr>";
outstr+=" <tr>";
outstr+=" <td><img src=\"http://www.mofao.com/images/2004_s_r4_c2.jpg\" width=\"59\" height=\"28\" ></td>";
outstr+=" <td background=\"http://www.mofao.com/images/2004_s_r4_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Copper+"</td>";
outstr+=" </tr>";
outstr+="</table>";
<%
end if
%>
document.write(outstr)