几种生成网站首页的方法

发布时间:2008-10-22 发布者:新锐传媒 查阅 [3992] 评论 [0]

    网站建设好了,为了使搜索引擎更好的抓取你的网站首页,一般情况下,我们会将ASP首页生成静态的htm或者html页面,生成静态首页主要有以下几种方法,每种方法都是经过我们测试过的,大家可以直接套用.

方法一CODE:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>生成首页</title>
</head>

<body>
<%
if request("act")="ok" then
mbStr=request("mbstr")
set fso=createobject("scripting.filesystemobject")
set fw=fso.createtextfile(server.mappath("/index.htm"),true)
fw.writeline mbStr
fw.close
set fso=nothing
response.Write("首页生成完成")
else
%>
<form name="form1" method="post" action="?act=ok">
<input type="submit" name="Submit" value=" 生 成 首 页 ">
<textarea name="mbstr" rows="40" id="mbstr" style="width:100% ">
<!--#include file="default.asp"-->
</textarea>
</form>
<%
end if
%>
</body>
</html>
方法二CODE:
<%
randomize()
if SaveFile("/index.htm","http://www.wl168.com/index.asp?rnd=" & rnd()*100 &"") then
 Response.write "已生成"
else
 Response.write "没有生成"
end if

function SaveFile(LocalFileName,RemoteFileUrl)
 Dim Ads, Retrieval, GetRemoteData
 On Error Resume Next
 Set Retrieval = Server.CreateObject("Microso" & "ft.XM" & "LHTTP")
 With Retrieval
  .Open "Get", RemoteFileUrl, False, "", ""
  .Send
  GetRemoteData = .ResponseBody
 End With
 Set Retrieval = Nothing
 Set Ads = Server.CreateObject("Ado" & "db.Str" & "eam")
 With Ads
  .Type = 1
  .Open
  .Write GetRemoteData
  .SaveToFile Server.MapPath(LocalFileName), 2
  .Cancel()
  .Close()
 End With
 Set Ads=nothing
 if err <> 0 then
  SaveFile = false
  err.clear
 else
  SaveFile = true
 end if
End function
%>

 

      免责声明 | 新锐观点 | 网站运营 | 网站推广 | 联系我们 | 网站地图