当前位置: 首页IT技术 → Asp生成html实例代码的分享

Asp生成html实例代码的分享

更多

这是一个ASP生成html的代码,现在拿出来跟大家一起分享,希望对正在学习ASP的朋友们能够有所帮助。

<%
Function GetPage(url)
'获得文件内容
dim Retrieval
Set Retrieval = CreateObject("microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False ', "", ""
.Send
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function

Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
'++++++++++++++++++++++++++++++++++++++++++++++++生成HTML文件开始
on error resume next
Url="http://www.pc-5.cn/txt/index-txt.asp"'要读取的页面地址
wstr = GetPage(Url)

'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")

'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if

'要存放的页面地址
dizhi=server.MapPath("index.html")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If
Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
set CrFi=nothing
set fs=nothing
'++++++++++++++++++++++++++++++++++++++++++++++++生成HTML文件结束

'循环生成文章开始
for i=1 to 3026 step 1

'++++++++++++++++++++++++++++++++++++++++++++++++生成HTML文件开始
on error resume next
Url=http://www.pc-5.cn/txt/list.asp?id=100'要读取的页面地址
wstr = GetPage(Url)

'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")

'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if

'要存放的页面地址
dizhi=server.MapPath("100.html")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If
Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
set CrFi=nothing
set fs=nothing
'++++++++++++++++++++++++++++++++++++++++++++++++生成HTML文件结束

next

'循环生成文章结束
response.write("已经生成所有首页调用的标题,请返回!")
Response.redirect(request.servervariables("http_referer"))
%>

热门评论
最新评论
昵称:
表情: 高兴 可 汗 我不要 害羞 好 下下下 送花 屎 亲亲
字数: 0/500 (您的评论需要经过审核才能显示)