萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> java >> ASP常用函數自動獲取匹配文章標簽(Tags)、關鍵字:ShowTags()

ASP常用函數自動獲取匹配文章標簽(Tags)、關鍵字:ShowTags()

class="area"> 程序代碼
<%@LANGUAGE="VBSCRipT" CODEPAGE="65001"%>
<%
option explicit
response.charset = "UTF-8"
session.codepage = 65001
session.timeout = 1440
server.scripttimeout = 9999 '----------------------------------------------------
'功能: asp自動獲取匹配文章標簽(Tags)、關鍵字
'參數: strTitle 標題
'      strContent 內容
'返回: 0:無匹配標簽 其他:以英文半角逗號分隔的標簽列表
'說明:標簽關鍵字調用Discuz標簽關鍵字列表
'----------------------------------------------------
Function ShowTags(ByVal strTitle, ByVal strContent)
Dim xml, objNodes, XMLPath, i
strTitle = Server.URLEncode(strTitle)
strContent = Server.URLEncode(strContent)
XMLPath="http://keyWord.discuz.com/related_kw.html?title="&strTitle&"&content="&strContent&"&ics=utf-8&ocs=utf-8"
'From:http://www.hao3t.com
    Set XML = server.CreateObject("Microsoft.XMLDOM")
        With XML
        .async = "false"
        .resolveExternals = "false"
        .setPRoperty "ServerHTTPRequest", true
        .load(XMLPath)
            If .getElementsByTagName("info")(0).selectSingleNode("count").Text > 0 Then
            Set objNodes = .getElementsByTagName("item")
                For i = 0 to objNodes.length - 1
                ShowTags = ShowTags & Trim(objNodes(i).selectSingleNode("kw").Text)&","
                Next
            Set objNodes = Nothing
            ShowTags = Left(ShowTags,Len(ShowTags)-1)
            Else
            ShowTags = 0
            End If
        End With
    Set XML = Nothing
End Function '應用
Response.write ShowTags("Web開發相關")
%>
 
copyright © 萬盛學電腦網 all rights reserved