在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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; } } }
|
请发表评论