1.ASP转htm
2.如何利用fso将asp转化为html
ASP转htm
å°å¨æ页é¢è½¬æ¢çæéæHtmlæ件æ许å¤å¥½å¤ï¼æ¯å¦çæhtmlç½é¡µæå©äºè¢«æç´¢å¼ææ¶å½ï¼ç¹å«æ¯å¯¹æ¥åå¨æåæ°ç页é¢ï¼ãåå°è®¿é®æ¶ï¼è±ç¦»äºæ°æ®è®¿é®,源源码å轻对æ°æ®åºè®¿é®çååï¼å å¿«ç½é¡µæå¼é度ã
å½ç¶ï¼å¡äºæå©å¿ æå¼ï¼çæHTML页é¢æ å½¢ä¸ä¹è费大éçç£ç空é´ä»¥åæ¾è¿äºéææ件ï¼å¨ç¼è¾é¡µé¢è¿ç¨ä¸é¤è¯»åæ°æ®åºå¤ï¼ä¹è¦è¯»åæå¡å¨ç£çï¼é¡µé¢æ ·å¼çæ¹å¨å¿ é¡»éæ°çæå ¨é¨HTMLæ件ï¼ççã
åå¾å¤æç´¢å¼æï¼é½å¯ä»¥æ交ç½ç«ç页é¢å°åå表ï¼å¨ææ件çæ¶å½é®é¢å·²ç»ä¸ç®æ¯ä¸ªé®é¢äºï¼å¦google sitemapï¼ãå¾å¤±å°±è¦èªå·±è¡¡éææ¡äºï¼ä½æ 论å¦ä½ï¼æ们è¿æ¯è¦æå¾å¦ä½æä½çãè¿éå°±å¼ç¨ä¸ä¸å«äººçæç« è¯´æå ç§å¸¸è§ççææè·¯ï¼ä¾å¤§å®¶åèåèã
1ãä¸é¢è¿ä¸ªä¾åç´æ¥å©ç¨FSOæhtml代ç åå ¥å°æ件ä¸ç¶åçæ.htmlæ ¼å¼çæ件 ãè¿æ¯æåå§çï¼ä¼ç¹æ¯ç®åï¼ç¼ºç¹æ¯é¡µé¢çä¿®æ¹ä¸æ¹ä¾¿ï¼æä¸è¬ç¨å°çå°æ¹æ¯å©ç¨å®çææ´ç«åæ°æ件ãï¼é常ç½ç«å¦æ é¢ï¼å称çé ç½®ä¿åå¨æ°æ®åºï¼æå°å®çæconfig.aspä¿åè¿äºåéè°ç¨ï¼é¿å é¢ç¹è®¿é®æ°æ®åºï¼
-------------------------------------------------------------------------
以ä¸ä¸ºå¼ç¨çå 容ï¼
<%
filename="test.htm"
if request("body")<>"" then
set fso = Server.CreateObject("Scripting.FileSystemObject")
set htmlwrite = fso.CreateTextFile(server.mappath(""&filename&""))
htmlwrite.write "<html><head><title>" & request.form("title") & "</title></head>"
htmlwrite.write "<body>è¾åºTitleå 容: " & request.form("title") & "<br /> è¾åºBodyå 容:" & request.form("body")& "</body></html>" [ä¸å½ç«é¿ç«]
htmlwrite.close
set fout=nothing
set fso=nothing
end if
%>
<form name="form" method="post" action="">
<input name="title" value="Title" size=>
<br>
<textarea name="body">Body</textarea>
<br>
<br>
<input type="submit" name="Submit" value="çæhtml">
</form>
-----------------------------------------------------------------------------
2ãä½æ¯æç §ä¸é¢çæ¹æ³çæhtmlæ件é常ä¸æ¹ä¾¿ï¼ç¬¬äºç§æ¹æ³å°±æ¯å©ç¨æ¨¡æ¿ææ¯ï¼å°æ¨¡æ¿ä¸ç¹æ®ä»£ç çå¼æ¿æ¢ä¸ºä»è¡¨åææ¯æ°æ®åºå段ä¸æ¥åè¿æ¥çå¼ï¼å®æ模æ¿åè½ï¼å°æç»æ¿æ¢è¿çææ模æ¿ä»£ç çæHTMLæ件ãè¿ç§ææ¯éç¨å¾æ¯è¾å¤ï¼å¤§é¨åçCMSé½æ¯ä½¿ç¨è¿ç±»æ¹æ³ã
-----------------------------------------------------------------------------
以ä¸ä¸ºå¼ç¨çå 容ï¼
template.htm " //模æ¿æ件
<html>
<head>
<title>$title$ by webjx.com</title>
</head>
<body>
$body$
</body>
</html>
TestTemplate.asp "// çæHtml
<%
Dim fso,htmlwrite
Dim strTitle,strContent,strOut
"// å建æ件系ç»å¯¹è±¡
Set fso=Server.CreateObject("Scripting.FileSystemObject")
"// æå¼ç½é¡µæ¨¡æ¿æ件ï¼è¯»å模æ¿å 容
Set htmlwrite=fso.OpenTextFile(Server.MapPath("Template.htm"))
strOut=f.ReadAll
htmlwrite.close
strTitle="çæçç½é¡µæ é¢"
strC
"// ç¨çå®å 容æ¿æ¢æ¨¡æ¿ä¸çæ è®°
strOut=Replace(strOut,"$title$",strTitle)
strOut=Replace(strOut,"$body$",strContent)
"// å建è¦çæçéæ页
Set htmlwrite=fso.CreateTextFile(Server.MapPath("test.htm"),true)
"// åå ¥ç½é¡µå 容
htmlwrite.WriteLine strOut
htmlwrite.close
Response.Write "çæéæ页æåï¼"
"// éæ¾æ件系ç»å¯¹è±¡
set htmlwrite=Nothing
set fso=Nothing
%>
-----------------------------------------------------------------------------
3ã第ä¸ç§æ¹æ³å°±æ¯ç¨XMLHTTPè·åå¨æ页çæçHTMLå 容ï¼åç¨ADODB.Streamæè Scripting.FileSystemObjectä¿åæhtmlæ件ãæ¾å°ä¸æ®µXMLHTTPçæHtmlç代ç åèä¸ä¸ã
------------------------------------------------------------------------
以ä¸ä¸ºå¼ç¨çå 容ï¼
<%
"常ç¨å½æ°
"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,"GB")
set /news_con.asp?id="&id
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sText = getHTTPPage(txtURL)
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
filename=server.MapPath("/")&"/html/"&id&".html"
Set openFile=FileObject.OpenTextfile(filename,2,true) 'true为不存在自行建立
openFile.writeline(sText)
Set OpenFile=nothing
function checksql(kustr)
checksql=server.htmlencode(replace(replace(replace(kustr,"<>"," "),"* from "," "),"="," "))
end function
response.Write("<script language=javascript>alert('信息发布成功!');window.location.href='list.asp';</script>")
更多参考:/search.asp?搭建workflow 查看网页源码keyword=%C9%FA%B3%C9&cid=&Submit=%CB%D1%CB%F7