知识库

一段由ASP生成HTM简单实现的代码

来源: 本站    类别: 知识库    日期: 2014/9/1

 

<%
Function getHttpXML()
Set Http = Server.CreateObject("Msxml2.ServerXMLHTTP")
  dim lResolve,lConnect,lSend,lReceive
  lResolve = 5*1000
  lConnect = 5*1000
  lSend = 15*1000
  lReceive = 15*1000
  Http.setTimeouts lResolve,lConnect,lSend,lReceive
  Http.open "POST","http://www.cnhww.com",false '抓取需要生成html的页面
  Http.Send()
  if Http.readystate =1 then str1=timer()
  if Http.readystate =4 then str2=timer()
  if Http.readystate <> 4 then
  exit Function
  end if
  'if Http.readystate =0 then str1=timer()
  'getHttpXML=BytesToBstr(Http.responseBody,"utf-8")
  getHttpXML=Http.responseBody
  'getHttpXML=FormatNu(www.111cn.net)mber((str2-str1)/1000,3)
  if err.Number<>0 then err.Clear
End Function
'生成文件
Function SaveToFile()
    Dim objStream
    On Error Resume Next
    Set objStream = Server.CreateObject("ADODB.Stream")
    If Err.Number=-2147221005 Then
        Response.Write "<div align='center'>非常遗憾,您的主机不支持ADODB.Stream,不能使用本程序</div>"
        Err.Clear
        Response.End
    End If
    With objStream
        .Type = 1
        .Open
        .Charset = "utf-8"
        .write getHttpXML
        .SaveToFile Server.MapPath("index.html"),2
        .Close
    End With
    Set objStream = Nothing
End Function
call SaveToFile()


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com