首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

文章里动态关键字的做法,该如何处理

2012-01-21 
文章里动态关键字的做法我想问下那些大型门户网站里新闻的特定关键字是怎么做的就是像网易那里的一些特定

文章里动态关键字的做法
我想问下那些大型门户网站里新闻的特定关键字是怎么做的

      就是像网易那里的一些特定的关键字,会自动生成一个链接

[解决办法]
up
[解决办法]
C#原代源,如哪位高手有更好的做法请发到我邮箱,我的邮箱SAM_1031@163.COM
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;
}
}
}

热点排行