通过关键字构建标签-附上百度、搜狗和360搜索

2017-02-01 11:42:45  访问(2404) 赞(0) 踩(0)


    /// <summary>
    /// 关键字构建
    /// </summary>
    /// <param name="strKeyWord"></param>
    /// <param name="xdbHelper"></param>
    /// <returns></returns>
    protected string KeyWordBuild(string strKeyWord, DBHelper xdbHelper)
    {
        if (strKeyWord == null || strKeyWord.Length == 0)
            return "";

        string[] sA = strKeyWord.Trim().Split(',');

        StringBuilder sb = new StringBuilder();

        bool isFirst = true;
        string strTmp = null;
        string strUrl = null;

        string strHref = null;
        string strBaidu = null;
        string strSogou = null;
        string str360 = null;

        string strBaiduImg = "<img src=\""+strPhyPath+"/images/Baidu_16px.png\" border=\"0\" alt=\"\" />";
        string strSogouImg = "<img src=\"" + strPhyPath + "/images/sogou_16px.png\" border=\"0\" alt=\"\" />";
        string str360Img = "<img src=\"" + strPhyPath + "/images/360_16px.jpg\" border=\"0\" alt=\"\" />";
        string enText = null;

        foreach (string s in sA)
        {
            if (s == null || s.Length == 0)
                continue;

            strTmp = s.Trim();

            if (strTmp.Length == 0)
                continue;

            enText = Server.UrlEncode(strTmp);

            strUrl = strPhyPath + "/page_search.html?keyWord=" + enText;

            strHref = HtmlSlowXFunctions.GetHref(strUrl, strTmp, strTmp, "_blank");

            if (isFirst)
                isFirst = false;
            else
                sb.Append("&nbsp;&nbsp;&nbsp;");

            sb.Append(strHref);

            sb.Append("&nbsp;");

            // 百度链接 //
            strUrl = "https://www.baidu.com/s?word=" + enText;

            strBaidu = HtmlSlowXFunctions.GetHref
                (
                    strUrl,
                    strBaiduImg,
                    "百度一下:" + strTmp,
                    "_blank"
                );

            sb.Append("<sub>" + strBaidu + "</sub>");


            // 搜狗链接 //
            strUrl = "https://www.sogou.com/web?query=" + enText;

            strSogou = HtmlSlowXFunctions.GetHref
                (
                    strUrl,
                    strSogouImg,
                    "搜狗搜索:" + strTmp,
                    "_blank"
                );

            sb.Append("<sub>" + strSogou + "</sub>");


            // 360搜索 //
            strUrl = "https://www.so.com/s?q=" + enText;

            str360 = HtmlSlowXFunctions.GetHref
                (
                    strUrl,
                    str360Img,
                    "360搜索:" + strTmp,
                    "_blank"
                );

            sb.Append("<sub>" + str360 + "</sub>");

        }

        return sb.ToString();
    }


标签:逻辑代码    构建关键字    关键字标签 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)