将指定的asp文件内容生成HTML文件

 1   
 2Function GetPage(url)   
 3dim Retrieval   
 4Set Retrieval = CreateObject("Microsoft.XMLHTTP")   
 5With Retrieval   
 6.Open "Get", url, False ', "", ""   
 7.Send   
 8GetPage = BytesToBstr(.ResponseBody)   
 9End With   
10Set Retrieval = Nothing   
11End Function 
12
13Function BytesToBstr(body)   
14dim objstream   
15set objstream = Server.CreateObject("adodb.stream")   
16objstream.Type = 1   
17objstream.Mode =3   
18objstream.Open   
19objstream.Write body   
20objstream.Position = 0   
21objstream.Type = 2   
22objstream.Charset = "GB2312"   
23BytesToBstr = objstream.ReadText   
24objstream.Close   
25set objstream = nothing   
26End Function   
27on error resume next   
28Url=" http://www.taiang.com.cn/index.asp "   
29response.write "开始更新首页..."   
30wstr = GetPage(Url) 
31
32Set fs=Server.CreateObject("Scripting.FileSystemObject") 
33
34'if not MyFile.FolderExists(server.MapPath("/html/")) then   
35'MyFile.CreateFolder(server.MapPath("/html/"))'   
36'end if 
37
38If (fs.FileExists(server.MapPath("./")&"\index.htm")) Then   
39fs.DeleteFile(server.MapPath("./")&"\index.htm")   
40End If 
41
42Set CrFi=fs.CreateTextFile(server.MapPath("./")&"\index.htm")   
43Crfi.Writeline(wstr)   
44set CrFi=nothing   
45set fs=nothing   
46response.write "...

<font color="red">更新完成!</font>

1"   
Published At
Categories with Web编程
Tagged with
comments powered by Disqus