using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Xml;  
using System.Net;  
using System.IO;  
namespace BLL  
{  
public class Alexa  
{  
public static int GetAlexa(string host)  
{  
string html = Net.GetHtml("http://data.alexa.com/data/?cli=10&dat=snba&ver=7.0&url=" + host);  
try  
{  
XmlDocument xml 
= new XmlDocument();  
xml.LoadXml(html);  
XmlNode node 
= xml.SelectSingleNode("/ALEXA/SD/POPULARITY");  
if (node != null && node.Attributes["TEXT"!= null)  
return int.Parse(node.Attributes["TEXT"].Value);  
}  
catch  
{  
int a = html.IndexOf("RANK=\"");  
if (a > 0)  
{  
int b = html.IndexOf("\"", a+6);  
if (b>0)  
return int.Parse(html.Substring(a+6, b-a-6));  
}  
}  
return 0;  
}  
}  
}  

 

posted on 2009-12-11 16:10  kuibono  阅读(428)  评论(3编辑  收藏  举报

爱造人 | 快播影视