當(dāng)前位置:首頁(yè)文章首頁(yè) IT學(xué)院 IT技術(shù)

Asp生成html實(shí)例代碼的分享

作者:  來源:  發(fā)布時(shí)間:2011-6-2 9:35:55  點(diǎn)擊:

這是一個(gè)ASP生成html的代碼,現(xiàn)在拿出來跟大家一起分享,希望對(duì)正在學(xué)習(xí)ASP的朋友們能夠有所幫助。

<%
Function GetPage(url)
'獲得文件內(nèi)容
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"'要讀取的頁(yè)面地址
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

'要存放的頁(yè)面地址
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文件結(jié)束

'循環(huán)生成文章開始
for i=1 to 3026 step 1

'++++++++++++++++++++++++++++++++++++++++++++++++生成HTML文件開始
on error resume next
Url=http://www.pc-5.cn/txt/list.asp?id=100'要讀取的頁(yè)面地址
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

'要存放的頁(yè)面地址
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文件結(jié)束

next

'循環(huán)生成文章結(jié)束
response.write("已經(jīng)生成所有首頁(yè)調(diào)用的標(biāo)題,請(qǐng)返回!")
Response.redirect(request.servervariables("http_referer"))
%>

文章評(píng)論

軟件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z