国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

動(dòng)態(tài)網(wǎng)站首頁的靜態(tài)生成方法

2019-11-18 19:23:45
字體:
供稿:網(wǎng)友

方法一

<%

'常用函數(shù)
'1、輸入url目標(biāo)網(wǎng)頁地址,返回值getHTTPPage是目標(biāo)網(wǎng)頁的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

'2、轉(zhuǎn)換亂瑪,直接用xmlhttp調(diào)用有中文字符的網(wǎng)頁得到的將是亂瑪,可以通過adodb.stream組件進(jìn)行轉(zhuǎn)換
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

 

txtURL=server.MapPath("../index.asp")

sText = getHTTPPage(txtURL)

Set FileObject=Server.CreateObject("Scrfilename="../index.htm"
Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) 'true為不存在自行建立
openFile.writeline(sText)
Set OpenFile=nothing

%>
<script>
alert("靜態(tài)網(wǎng)頁生成完畢");
history.back();
</script>

方法二:

 resourcefile=server.MapPath("../index.asp")
  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


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 罗田县| 敦煌市| 绩溪县| 宁南县| 科技| 古田县| 东山县| 天镇县| 弥勒县| 安新县| 柘荣县| 神农架林区| 黑河市| 和田市| 临城县| 合肥市| 筠连县| 梨树县| 池州市| 碌曲县| 宁南县| 金沙县| 河曲县| 台南市| 措勤县| 安龙县| 永年县| 漾濞| 峨山| 濉溪县| 绍兴县| 上思县| 龙门县| 涿鹿县| 柳林县| 金昌市| 光泽县| 恩施市| 应城市| 确山县| 盘锦市|