首页  »  网页设计教程  »  动态网站首页的静态生成方式

动态网站首页的静态生成方式

浏览数:共 655 次     评论:共 0 条     发布日期:2011-08-17     分类:asp

"1、输入url目标网页地址,返回值gethttppage是目标网页的html代码
function gethttppage(url)
dim http
set http=server.createobject("msxml2.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

filename="../index.htm"
set openfile=fileobject.opentextfile(server.mappath(filename),2,true) "true为不存在自行建立
openfile.writeline(stext)
set openfile=nothing

<script>
alert("静态网页生成完毕");
history.back();
</script>

targetfile=server.mappath("../index.htm")
set html = server.createobject("cdo.message")
html.createmhtmlbody resourcefile,31
indexcode=html.htmlbody
set html = nothing
if instr(indexcode,"</body></html>")<=0 then
response.write("首页生成失败")
response.end()
else
set ofilesys = server.createobject("scripting.filesystemobject")
set outfile=ofilesys.createtextfile(targetfile)
outfile.writeline indexcode
outfile.close
set outfile=nothing
set ofilesys=nothing
response.write("首页生成完毕!")
end if



上一篇:初试WAP之wml+ASP查询
下一篇:利用正则表达式实现模式图片新闻-ASP