我想问下那些大型门户网站里新闻的特定关键字是怎么做的   就是像网易那里的一些特定的关键字,会自动生成一个链接

解决方案 »

  1.   

    C#原代源,如哪位高手有更好的做法请发到我邮箱,我的邮箱[[email protected]][email protected][/email]
        private string AddKeyWord(string strInfo,string strKeyWord,string strKeyWordUrl)
        {
            string strInfos = "";
            int count;
            string strUrl = "<a href=\"" + strKeyWordUrl + "\">" + strKeyWord + "</a>";
            while (true)
            {
                count = strInfo.IndexOf("<");
                if (count != -1)
                {
                    strInfos += strInfo.Substring(0, count).Replace(strKeyWord, strUrl);
                    strInfo = strInfo.Substring(count);
                    count = strInfo.IndexOf(">");
                    if (count != -1)
                    {
                        if (strInfo.Substring(0, 2).ToLower() == "<a")
                        {
                            count = strInfo.ToLower().IndexOf("</a>") + 4;
                            strInfos += strInfo.Substring(0, count);
                            strInfo = strInfo.Substring(count);                    }
                        else
                        {
                            count++;
                            strInfos += strInfo.Substring(0, count);
                            strInfo = strInfo.Substring(count);
                        }
                    }
                    else
                    {
                        strInfos += strInfo;
                        return strInfos;
                    }
                }
                else
                {
                    strInfos += strInfo.Replace(strKeyWord, strUrl);
                    return strInfos;
                }
            }
        }
      

  2.   

    如果你用第三方的全文检索引擎...比如说SPS的.他的爬网引擎会给你解决这个问题的.
    如果是你自己写的,最好还是弄个关键字列表吧.好处多,又可以分类相关新闻,又可以方便检索.
      

  3.   

    我的新闻系统里做了这个功能,一切靠js功底
    http://www.rrsou.com/news.aspx?id=7304&page=1