<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Option Explicit Const Msxml="Msxml2.XMLHTTP" ' "MSXML2.ServerXMLHttp" 或 "Msxml2.XMLHTTP" Const FsObject="Scripting.FileSystemObject" Const FsObject1=0 Dim action '选择生成类型 action=Request.QueryString("action") Select Case action Case "cd3day"'3天 If IsDate(Application("3CeratHtmlIndexUs39fYvnSv"))=False then Application("3CeratHtmlIndexUs39fYvnSv")="2009-5-03 01:01:01" If DateDiff("s",Application("3CeratHtmlIndexUs39fYvnSv"),now())=>18777 then ' HtmlSave "/SV_print/tq/cd_3.asp","/SV_print/tq/up/tq.htm" '注意路径 Application.Lock Application("3CeratHtmlIndexUs39fYvnSv")=now() Application.Unlock End if Case "cd7day"'7天 If IsDate(Application("7CeratHtmlIndex6sU4gDfj39"))=False then Application("7CeratHtmlIndex6sU4gDfj39")="2009-5-03 01:01:01" If DateDiff("s",Application("7CeratHtmlIndex6sU4gDfj39"),now())=>10999 then ' HtmlSave "/SV_print/tq/cd_7.asp","/SV_print/tq/up/7tq.htm" '注意路径 Application.Lock Application("7CeratHtmlIndex6sU4gDfj39")=now() Application.Unlock End if End Select Function HtmlSave(Url,FileSavePath) Dim Fso,Str HtmlSave=false Url="http://"& Request.ServerVariables("SERVER_NAME") & Url Str=GetHttpPage(Url) If Str="" Then Exit Function If FsObject1=0 Then Set Fso = Server.Createobject("Scripting.FileSystemObject") Set Fso = Fso.CreateTextFile(Server.mappath(FileSavePath),true,True) Fso.Write Str Fso.Close:Set Fso=NoThing Else Set Fso = Server.CreateObject("ADODB.Stream") Fso.Type = 2 Fso.Open Fso.Charset = "utf-8" Fso.Position = Fso.Size Fso.WriteText Str Fso.SaveToFile FileSavePath,2 Fso.close:Set Fso=Nothing End If HtmlSave=True End Function '================================================== '函数名:GetHttpPage '作 用:获取网页源码 '参 数:HttpUrl ------网页地址 '================================================== Function GetHttpPage(HttpUrl) dim http Set http=server.createobject(Msxml) Http.open "GET",HttpUrl,false On Error Resume Next Http.send() If Http.readystate<>4 Then Exit Function GetHttpPage=BytesToBstr(Http.ResponseBody,"utf-8") If InStr(Lcase(getHTTPPage), "charset=utf-8") Then getHTTPPage=Http.responseText Set http=nothing if err.number<>0 then err.Clear End Function '================================================== '函数名:BytesToBstr '作 用:将获取的源码转换为中文 '参 数:Body ------要转换的变量 '参 数:Cset ------要转换的类型 '================================================== 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 %>