<!--#include file= "conn.asp"
<%
db= "Database/database.mdb"
Path=server.mappath (DB)
Set Conn=server.createobject ("ADODB. Connection ")
connstr=" Provider=Microsoft.Jet.OLEDB.4.0;Data source= "&path
Conn. The Open connstr
Set rs=server. CreateObject ("Adodb.recordset")
%>
<%
sql= "SELECT * from News"
rs.open sql,conn,1,1
If rs.eof Then
Else&nbs p;
path5= "./html/" ' This is the post-build file path
do, not rs.eof
Filename=replace (replace (replace (RS ("Addtime"), ":", ""), "-", ""), "", "" ") &". html "' This is the file name after the build
url= "http://localhost/netfriend/news.asp?id=" &rs ("id") ' This is a dynamic page address and must be http://***
call createhtml (URL,FILENAME,PATH5)
in *.asp format rs.movenext
loop
End If
Rs.close
set rs=nothing
Set conn=nothing
%>
<%
' Features: Reading database tutorial content, generating Static page
' from: www.111cn.net
' Author: wangsdong
' parameter description:
' URL is dynamic page address, must be http://*****/* The *.asp format
' filename is the generated filename
' path is the folder name for storing the generated files
' Note: Support original program, please keep this information, thank you
Function createhtml (url,filename,path)
Set myfileobject=server.createobject ("Scripting.FileSystemObject")
Path1=server.mappath (Path) & "&filename
Set mytextfile=myfileobject.createtextfile (path1)
strurl=url
strtmp = gethttppage (Trim (strurl))
Mytextfile.writeline (strtmp)
Mytextfile.close
Response.Write Build &filename& Success <br>
Set myfileobject=nothing
End Function
Function gethttppage (URL)
on Error Resume Next
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
Response.Write "<p align= ' center ' >< Font color= ' Red ' ><b> server gets file contents error </b></font></p> '
err.clear
end If
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
%>
news.asp file
<!--#include file= "Www.111cn.net"-->
<%
Id=request ("id")
Sql= "SELECT * from news where id=" &id
Rs.Open sql,conn,1,1
If rs.eof Then
Else
Title=rs ("title")
Content=rs ("content")
End If
Rs.close
%>
<style>
Body td {FONT-SIZE:12PX;}
</style>
<TITLE> <%=title%> </title>
<table Border= "0" cellpadding= "0" cellspacing= "0" width= "" "
<tr>
<td style= "border-bottom:1px #cccccc solid; height:40px; Font-weight:bold; Text-align:center; " ><%=title%></td>
</tr>
<tr>
&NBSP;<TD align= "center" ><div style= "margin-top:20px; width:95% "><%=content%></div></td>
</tr>
</table "