当前位置:编程学习 > asp >>

asp自动生成html并覆盖原html

答案:

dim read,Curl,content

 


Function getHTTPPage(url)
  dim http
  set http=Server.createobject("Microsoft.XMLHTTP")
  Http.open "GET",url,false
  Http.send()
  if Http.readystate<>4 then
    exit function
  end if
  getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
  set http=nothing
  if err.number<>0 then err.Clear
End function

Function BytesToBstr(body,Cset)
  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 = Cset
  BytesToBstr = objstream.ReadText
  objstream.Close
  set objstream = nothing
End Function

Curl="http://localhost/index.asp"
read=getHTTPPage(Curl)

if read<>"" then
  content=read
  Set Fso = Server.CreateObject("Scripting.FileSystemObject")
  Filen=Server.MapPath("index.html")
  Set Site_Config=FSO.CreateTextFile(Filen,true, False)
  Site_Config.Write content
  Site_Config.Close
  Set Fso = Nothing
  Response.Write("<script>alert('已经成功生成首页!')</script>")
end if

上一个:长文章自动分页类
下一个:创建一个简单的ASP页

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,