工作之余写了一段asp生成静态网页的代码,大家指点一下
Function AddNewNews(Caption,Content,ClassID,pic,fabuzhe,webname)
if GetStrLen(caption)>50 then
AddNewNews=GoBack("","建议新闻主题不要超过50个字符")
exit Function
else
sql="Insert Into 365Days_NewsInfo (Caption,Content,classid,pic,fabuzhe,webname) values('"&Caption&"','"&Content&"',"&ClassID&",'"&pic&"','"&fabuzhe&"','"&webname&"')"
conn.execute(sql)
sql1="SELECT Max([365Days_NewsInfo].ID) as id FROM 365Days_NewsInfo"
set rs=conn.execute(sql1)
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Item_Classid = rs("id")
FileName = webname&".htm"
FilePath = Server.MapPath("/xhfwq")&"\"&FileName
'Do_Url = "http://"
'Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME")&"/main/index.asp"
'Do_Url = Do_Url&"?Item_Classid="&Item_Classid
strUrl ="http://192.168.0.51/gsgl/newsdetail.asp?id="&Item_Classid&""
'Do_Url = "http://"
'Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME")&"/main/index.asp"
'Do_Url = Do_Url&"?Item_Classid="&Item_Classid
'strUrl = Do_Url
dim objXmlHttp
set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
Dim objAdoStream
set objAdoStream = Server.CreateObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()
if classid<>6 and classid<>7 then
AddNewNews=Suc("","新闻信息添加成功","365Days_News.asp?Action=Infolist")
else
AddNewNews=Suc("","信息添加成功","365Days_fuwuzhinan.asp?Action=Canyinjk")
end if
end if
End Function