<%
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 = “utf-8″
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
on error resume next
Url=”http://www.lnpfbyy.com/index4.asp”‘要读取的页面地址
response.write “开始更新首页…”
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
‘要存放的页面地址
oStream.CharSet = “gb2312″
dizhi=server.MapPath(“/index.html”)
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If

Set stm = CreateObject(“Adodb.Stream”)
stm.Type = 2
stm.mode = 3
stm.charset = “utf-8″
‘上面修改生成的网页编码
stm.Open
stm.WriteText wstr
stm.SaveToFile dizhi, 2
stm.flush
stm.Close
Set stm = Nothing
response.write “…<font color=red>更新完成!</font>”
%>

第二种方式:

<%
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 = “utf-8″
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
on error resume next
Url=”http://www.syhqyy.com/index.asp”‘要读取的页面地址
response.write “33″
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
response.write “<font color=red>11</font>”

Set   objStream   =   Server.CreateObject(“ADODB.Stream”)
With   objStream
.Open
.Charset   =   “utf-8″
.Position   =   objStream.Size
.WriteText = wstr
.SaveToFile   server.mappath(“/index.html”),2
.Close
End   With
Set   objStream   =   Nothing
response.write “<font color=red>11</font>”
%>

原创文章,转载请注明: 转载自老姜的博客

本文链接地址: 将指定的asp网页文件生成特定编码的html网页

无觅相关文章插件,快速提升流量

|2|left|yes