{"id":71,"date":"2007-09-24T16:00:54","date_gmt":"2007-09-24T08:00:54","guid":{"rendered":"http:\/\/www.cnmiss.cn\/?p=70"},"modified":"2010-12-02T06:31:28","modified_gmt":"2010-12-02T06:31:28","slug":"asp%e7%94%9f%e6%88%90%e9%9d%99%e6%80%81html%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/www.cnmiss.cn\/?p=71","title":{"rendered":"ASP\u751f\u6210\u9759\u6001Html\u6587\u4ef6"},"content":{"rendered":"<p>\u7f51\u9875\u751f\u6210\u9759\u6001Html\u6587\u4ef6\u6709\u8bb8\u591a\u597d\u5904,\u6bd4\u5982\u751f\u6210html\u7f51\u9875\u6709\u5229\u4e8e\u88ab\u641c\u7d22\u5f15\u64ce\u6536\u5f55,\u4e0d\u4ec5\u88ab\u6536\u5f55\u7684\u5feb\u8fd8\u6536\u5f55\u7684\u5168.\u524d\u53f0\u8131\u79bb\u4e86\u6570\u636e\u8bbf\u95ee,\u51cf\u8f7b\u5bf9\u6570\u636e\u5e93\u8bbf\u95ee\u7684\u538b\u529b,\u52a0\u5feb\u7f51\u9875\u6253\u5f00\u901f\u5ea6.  <\/p>\n<blockquote><p>1,\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\u76f4\u63a5\u5229\u7528FSO\u628ahtml\u4ee3\u7801\u5199\u5165\u5230\u6587\u4ef6\u4e2d\u7136\u540e\u751f\u6210.html\u683c\u5f0f\u7684\u6587\u4ef6 &lt;% <br \/>filename=&quot;test.htm&quot; <br \/>if request(&quot;body&quot;)&lt;&gt;&quot;&quot; then <br \/>set fso = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;) <br \/>set htmlwrite = fso.CreateTextFile(server.mappath(&quot;&quot;&#038;filename&#038;&quot;&quot;)) <br \/>htmlwrite.write &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;&quot; &#038; request.form(&quot;title&quot;) &#038; &quot;&lt;\/title&gt;&lt;\/head&gt;&quot; <br \/>htmlwrite.write &quot;&lt;body&gt;\u8f93\u51faTitle\u5185\u5bb9: &quot; &#038; request.form(&quot;title&quot;) &#038; &quot;&lt;br \/&gt; \u8f93\u51faBody\u5185\u5bb9:&quot; &#038; request.form(&quot;body&quot;)&#038; &quot;&lt;\/body&gt;&lt;\/html&gt;&quot; <br \/>htmlwrite.close <br \/>set fout=nothing <br \/>set fso=nothing <br \/>end if <br \/>%&gt; <br \/>&lt;form name=&quot;form&quot; method=&quot;post&quot; action=&quot;&quot;&gt; <br \/>&lt;input name=&quot;title&quot; value=&quot;Title&quot; size=26&gt; <br \/>&lt;br&gt; <br \/>&lt;textarea name=&quot;body&quot;&gt;Body&lt;\/textarea&gt; <br \/>&lt;br&gt; <br \/>&lt;br&gt; <br \/>&lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;\u751f\u6210html&quot;&gt; <br \/>&lt;\/form&gt; <br \/>2,\u4f46\u662f\u6309\u7167\u4e0a\u9762\u7684\u65b9\u6cd5\u751f\u6210html\u6587\u4ef6\u975e\u5e38\u4e0d\u65b9\u4fbf,\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u5c31\u662f\u5229\u7528\u6a21\u677f\u6280\u672f,\u5c06\u6a21\u677f\u4e2d\u7279\u6b8a\u4ee3\u7801\u7684\u503c\u66ff\u6362\u4e3a\u4ece\u8868\u5355\u6216\u662f\u6570\u636e\u5e93\u5b57\u6bb5\u4e2d\u63a5\u53d7\u8fc7\u6765\u7684\u503c,\u5b8c\u6210\u6a21\u677f\u529f\u80fd;\u5c06\u6700\u7ec8\u66ff\u6362\u8fc7\u7684\u6240\u6709\u6a21\u677f\u4ee3\u7801\u751f\u6210HTML\u6587\u4ef6.\u8fd9\u79cd\u6280\u672f\u91c7\u7528\u5f97\u6bd4\u8f83\u591a,\u5927\u90e8\u5206\u7684CMS\u90fd\u662f\u4f7f\u7528\u8fd9\u7c7b\u65b9\u6cd5. <br \/>template.htm &#39; \/\/\u6a21\u677f\u6587\u4ef6 &lt;html&gt; <br \/>&lt;head&gt; <br \/>&lt;title&gt;$title$&lt;\/title&gt; <br \/>&lt;\/head&gt; <br \/>&lt;body&gt; <br \/>$body$ <br \/>&lt;\/body&gt; <br \/>&lt;\/html&gt; <\/p>\n<p>TestTemplate.asp &#39;\/\/ \u751f\u6210Html &lt;% <br \/>Dim fso,htmlwrite <br \/>Dim strTitle,strContent,strOut <br \/>&#39;\/\/ \u521b\u5efa\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61 <br \/>Set fso=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;) <br \/>&#39;\/\/ \u6253\u5f00\u7f51\u9875\u6a21\u677f\u6587\u4ef6\uff0c\u8bfb\u53d6\u6a21\u677f\u5185\u5bb9 <br \/>Set htmlwrite=fso.OpenTextFile(Server.MapPath(&quot;Template.htm&quot;)) <br \/>strOut=f.ReadAll <br \/>htmlwrite.close <\/p>\n<p>strTitle=&quot;\u751f\u6210\u7684\u7f51\u9875\u6807\u9898&quot; <br \/>strContent=&quot;\u751f\u6210\u7684\u7f51\u9875\u5185\u5bb9&quot; <\/p>\n<p>&#39;\/\/ \u7528\u771f\u5b9e\u5185\u5bb9\u66ff\u6362\u6a21\u677f\u4e2d\u7684\u6807\u8bb0 <br \/>strOut=Replace(strOut,&quot;$title$&quot;,strTitle) <br \/>strOut=Replace(strOut,&quot;$body$&quot;,strContent) <\/p>\n<p>&#39;\/\/ \u521b\u5efa\u8981\u751f\u6210\u7684\u9759\u6001\u9875 <br \/>Set htmlwrite=fso.CreateTextFile(Server.MapPath(&quot;test.htm&quot;),true) <\/p>\n<p>&#39;\/\/ \u5199\u5165\u7f51\u9875\u5185\u5bb9 <br \/>htmlwrite.WriteLine strOut <br \/>htmlwrite.close <\/p>\n<p>Response.Write &quot;\u751f\u6210\u9759\u6001\u9875\u6210\u529f\uff01&quot; <\/p>\n<p>&#39;\/\/ \u91ca\u653e\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61 <br \/>set htmlwrite=Nothing <br \/>set fso=Nothing <br \/>%&gt; <\/p>\n<p>3,\u7b2c\u4e09\u79cd\u65b9\u6cd5\u5c31\u662f\u7528XMLHTTP\u83b7\u53d6\u52a8\u6001\u9875\u751f\u6210\u7684HTML\u5185\u5bb9\uff0c\u518d\u7528ADODB.Stream\u6216\u8005Scripting.FileSystemObject\u4fdd\u5b58\u6210html\u6587\u4ef6\u3002\u8fd9\u53e5\u8bdd\u662f\u5728\u84dd\u8272\u7406\u60f3\u4e0a\u770b\u5230\u7684,\u5bf9XMLHTTP\u8fd8\u4e0d\u719f\u6089\u6b63\u5728\u627e\u8d44\u6599\u4e86\u89e3.\u627e\u5230\u4e00\u6bb5XMLHTTP\u751f\u6210Html\u7684\u4ee3\u7801\u53c2\u8003\u4e00\u4e0b. <br \/>&lt;% <\/p>\n<p>&#39;\u5e38\u7528\u51fd\u6570 <br \/>&#39;1\u3001\u8f93\u5165url\u76ee\u6807\u7f51\u9875\u5730\u5740\uff0c\u8fd4\u56de\u503cgetHTTPPage\u662f\u76ee\u6807\u7f51\u9875\u7684html\u4ee3\u7801 <br \/>function getHTTPPage(url) <br \/>dim Http <br \/>set Http=server.createobject(&quot;MSXML2.XMLHTTP&quot;) <br \/>Http.open &quot;GET&quot;,url,false <br \/>Http.send() <br \/>if Http.readystate&lt;&gt;4 then <br \/>exit function <br \/>end if <br \/>getHTTPPage=bytesToBSTR(Http.responseBody,&quot;GB2312&quot;) <br \/>set http=nothing <br \/>if err.number&lt;&gt;0 then err.Clear <br \/>end function <\/p>\n<p>&#39;2\u3001\u8f6c\u6362\u4e71\u739b\uff0c\u76f4\u63a5\u7528xmlhttp\u8c03\u7528\u6709\u4e2d\u6587\u5b57\u7b26\u7684\u7f51\u9875\u5f97\u5230\u7684\u5c06\u662f\u4e71\u739b\uff0c\u53ef\u4ee5\u901a\u8fc7adodb.stream\u7ec4\u4ef6\u8fdb\u884c\u8f6c\u6362 <br \/>Function BytesToBstr(body,Cset) <br \/>dim objstream <br \/>set objstream = Server.CreateObject(&quot;adodb.stream&quot;) <br \/>objstream.Type = 1 <br \/>objstream.Mode =3 <br \/>objstream.Open <br \/>objstream.Write body <br \/>objstream.Position = 0 <br \/>objstream.Type = 2 <br \/>objstream.Charset = Cset <br \/>BytesToBstr = objstream.ReadText <br \/>objstream.Close <br \/>set objstream = nothing <br \/>End Function <\/p>\n<p>txtURL=server.MapPath(&quot;..\/index.asp&quot;) <\/p>\n<p>sText = getHTTPPage(txtURL) <\/p>\n<p>Set FileObject=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;) <br \/>filename=&quot;..\/index.htm&quot; <br \/>Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) &#39;true\u4e3a\u4e0d\u5b58\u5728\u81ea\u884c\u5efa\u7acb <br \/>openFile.writeline(sText) <br \/>Set OpenFile=nothing <\/p>\n<p>%&gt; <br \/>&lt;script&gt; <br \/>alert(&quot;\u9759\u6001\u7f51\u9875\u751f\u6210\u5b8c\u6bd5&quot;); <br \/>history.back(); <br \/>&lt;\/script&gt; <\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u7f51\u9875\u751f\u6210\u9759\u6001Html\u6587\u4ef6\u6709\u8bb8\u591a\u597d\u5904,\u6bd4\u5982\u751f\u6210html\u7f51\u9875\u6709\u5229\u4e8e\u88ab\u641c\u7d22\u5f15\u64ce\u6536\u5f55,\u4e0d &hellip; <a href=\"https:\/\/www.cnmiss.cn\/?p=71\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-xxbj","tag-asp"],"_links":{"self":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":0,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}