8月28

简单的asp生成html代码

Large | Medium | Small
12:05 ASP  From: Original
Reads(7732) | Comments(0) | Trackbacks(0)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>

<body>
<%
call CreateHtml("../index.asp","/index.html")
Function CreateHtml(RemoteFileUrl,LocalFileName)
dim objXmlHttp
set objXmlHttp = Server.CreateObject("Micr"&"oso"&"ft.XM"&"LHT"&"TP")

'后台目录url
http=request.ServerVariables("HTTP_REFERER")
http=Mid(http,1,InStrRev(http,"/"))
if InStr(lcase(RemoteFileUrl),"http://")<=0 then
RemoteFileUrl=http&RemoteFileUrl
end if

if instr(RemoteFileUrl,"?")>0 then
RemoteFileUrl2=RemoteFileUrl&"&getkey_n="&getkey_n(6)
else
RemoteFileUrl2=RemoteFileUrl&"?getkey_n="&getkey_n(6)
end if

objXmlHttp.open "GET",RemoteFileUrl2,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
Dim objAdoStream
set objAdoStream = Server.CreateObject("ADO"&"DB.Str"&"eam")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile server.MapPath(LocalFileName),2
objAdoStream.Close()
response.write("生成:<a href="""&LocalFileName&""" target=""_blank"">"&LocalFileName&"</a> 成功!<br/>"&vbcrlf)
response.Flush()
End Function

'随机数字
Function getkey_n(digits)
dim char_array(50),output,num
output=""
char_array(0) = "0"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
randomize
do while len(output) < digits
num = char_array(Int((9 - 0 + 1) * Rnd + 0))
output = output + num
loop
getkey_n = output
End Function
%>
</body>
</html>


保存为 asp 文件 放到 admin目录下,运行就可以生成首页了。

调用 call CreateHtml("../index.asp","/index.html") 可以进行相应的修改

第一个参数为相对路径 也可以用绝对路径(http://...)的asp文件

第二个参数为相对路径 也可以用更目录绝对路径(/...) 的html文件
飞鸟ASP生成HTM插件http://www.zhouhaihe.com/asp-to-htm/
Download ( 422 downloads)

Last modified by tommyhu on2009/08/28 12:08
Add a comment
Emots
emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot
Enable HTML
Enable UBB
Enable Emots
Hidden
Remember

Nickname : 

Password(可不填) :  Optional

Site URI (可不填) : 

Email (可不填) :  [Register]