Written on 2008年10月9日 @ 09:17 | by szetom | Tags: ALEXA排名  

分享我写的查ALEXA排名的函数,返回值为-1表示出错,没获取到排名值.
MyEncode.GetUrl(string url)函数的作用是获取网页源代码.
MyEncode.StrCut(string str,string str1,string str2,int mode)函数的作用是从字符串str中截取开头为str1,结尾为str2的字符串.
以上函数来自我的自定义函数类,就不公布了,大家应该可以想到解决的办法.

    //查询Alexa排名
    public static int GetAlexa(string url)
    {
        try
        {
            string html = MyEncode.GetUrl("http://data.alexa.com/data/?cli=10&dat=snba&ver=7.0&url=" + url);
            if (html.Length > 0)
            {
                string alexa = MyEncode.StrCut(html, "/\" TEXT=\"", "\"", 2);
                return Int32.Parse(alexa);
            }
        }
        catch { }
        return -1;
    }

相关文章:

  1. 1 Response to “查ALEXA排名的方法,C#函数”

  2. By emao on 2008年10月9日 | http://7751.cn

    晕.你这也叫分享.....

Post a Comment

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

About Me

致力于研究搜索引擎排名,拥有丰富的SEO优化经验,提供详细的SEO优化技术及由酷酷虎开发的各种工具软件.
QQ:
Email:

Find entries :