如何通过编程方式获取alexa排名的数据 |
发布时间: 2012/8/27 9:41:36 |
Alexa 是以发布世界网站排名而引人注目的一个网站。其实,此网站的搜索引擎也很好用,但是“网站排名”却是它吸引眼球的最主要原因。
以网站导航起家的Alexa创建于1996年4月,他们的目的是让Internet冲浪者在分享虚拟世界资源的同时,更多地参与Internet资源的组织。2002年5月Alexa放弃了自己的搜索引擎与Google合作。他们每天在网上搜集超过1,000GB的信息,然后进行整合发布。现在他们搜集的URL数量已经超过了Google。下图是他们自己给出的一个信息量比较图。纵轴为已有的URL地址的量,以十亿为单位。也就是说在量上,Alexa位居世界四大名搜索引擎第一位,已经超过了350亿。焦点在于,Alexa不仅给出这350多亿网址的链接,而且为其中的每一个网站进行了排名。可以说,Alexa是当前拥有URL数量最庞大,排名信息发布最详尽的网站。 Alexa的世界网站排名主要分两种:综合排名,可以叫做绝对排名,即特定的一个网站在所有350多亿网站中的名次。Alexa每三个月公布一次新的网站综合排名。此排名的依据是用户链接数(Users Reach)和页面浏览数(Page Views)三个月累积的几何平均值。分类排名一是按主题分类,比如新闻、娱乐、购物等,Alexa给出某个特定网站在同一类网站中的名次。Alexa将其收集到的网站共分了16个大类,每个类下又分为多个主题。 阿里妈妈的网站也有Alexa网站排名(http://tool.alimama.com/site.php)、中国站长网站(http://alexa.chinaz.com/Index.asp)也提供Alexa排名查询,还有很多网站也提供了它们的Alexa排名,这些排名的数据都是通过调用称为Alexa Web Information Service (AWIS)的服务,地址是http://awis.amazonaws.com/doc/2005-07-11/AWSAlexa.wsdl。 那么我们如何才能使用这些服务,以便创建我们的Alexa排名查询操作呢? 1. 首先你通过网站连接http://www.amazon.com/gp/browse.html?node=12782661,了解它是做什么的,收费如何(1000次约人民币1元左右)。 2. 注册一个帐号,绑定您的银行卡或者信用卡 3. 成功后会给你一个发送一个邮件,并可以登录查看你的专用公钥私钥字符串。 4. 根据这些你就可以访问它的AWIS访问了,如果你要了解进一步的开发的话,请参考这里的文档: http://docs.amazonwebservices.com/AlexaWebInfoService/2005-07-11/ 5. 如果你有疑问,可以在论坛中询问,当然都是老外的了。http://developer.amazonwebservices.com/connect/forum.jspa?forumID=14 6.AWIS有很多Response,如UrlInfoResponseResponse、CategoryBrowseResponseResponse、SitesLinkingInResponseResponse、TrafficHistoryResponseResponse、CategoryListingsResponseResponse、CrawlResponseResponse等,这些包含了各类排名等数据。 7. 我调用了AWIS做了一个小的测试应用,程序界面如下: 8. 最后贴一些代码辅助大家 获取Response的信息#region 获取Response的信息 public UrlInfoResponseResponse GetUrlInfoResponse(string website, string action, string responseGroup) { string timestamp = Helper.GetTimestamp(); string signature = Helper.MakeSignature(action + timestamp, privateKey); //Set the request security settings UrlInfoRequestSecurity usecurity = new UrlInfoRequestSecurity(); usecurity.AWSAccessKeyId = publicKey; usecurity.Signature = signature; usecurity.Timestamp = timestamp; UrlInfoRequest request = new UrlInfoRequest(); request.Url = website; request.ResponseGroup = responseGroup; request.Security = usecurity; UrlInfo urlInfo = new UrlInfo(); urlInfo.Request = request; AWSAlexa alexa = new AWSAlexa(); UrlInfoResponse uresponse = alexa.UrlInfo(urlInfo); return uresponse.Response; } public CategoryBrowseResponseResponse GetCategoryBrowseResponse(string website, string action, string responseGroup, string path, bool description) { string timestamp = Helper.GetTimestamp(); string signature = Helper.MakeSignature(action + timestamp, privateKey); //Set the request security settings CategoryBrowseRequestSecurity usecurity = new CategoryBrowseRequestSecurity(); usecurity.AWSAccessKeyId = publicKey; usecurity.Signature = signature; usecurity.Timestamp = timestamp; CategoryBrowseRequest request = new CategoryBrowseRequest(); request.ResponseGroup = responseGroup; request.Security = usecurity; request.Path = path; request.Descriptions = description.ToString(); CategoryBrowse browse = new CategoryBrowse(); browse.Request = request; AWSAlexa alexa = new AWSAlexa(); CategoryBrowseResponse uresponse = alexa.CategoryBrowse(browse); return uresponse.Response; } public SitesLinkingInResponseResponse GetSitesLinkingInResponse(string website, string action, string responseGroup) { string timestamp = Helper.GetTimestamp(); string signature = Helper.MakeSignature(action + timestamp, privateKey); //Set the request security settings SitesLinkingInRequestSecurity usecurity = new SitesLinkingInRequestSecurity(); usecurity.AWSAccessKeyId = publicKey; usecurity.Signature = signature; usecurity.Timestamp = timestamp; SitesLinkingInRequest request = new SitesLinkingInRequest(); request.ResponseGroup = responseGroup; request.Security = usecurity; request.Url = website; SitesLinkingIn browse = new SitesLinkingIn(); browse.Request = request; AWSAlexa alexa = new AWSAlexa(); SitesLinkingInResponse uresponse = alexa.SitesLinkingIn(browse); return uresponse.Response; } public TrafficHistoryResponseResponse GetTrafficHistoryResponse(string website, string action, string responseGroup) { string timestamp = Helper.GetTimestamp(); string signature = Helper.MakeSignature(action + timestamp, privateKey); //Set the request security settings TrafficHistoryRequestSecurity usecurity = new TrafficHistoryRequestSecurity(); usecurity.AWSAccessKeyId = publicKey; usecurity.Signature = signature; usecurity.Timestamp = timestamp; TrafficHistoryRequest request = new TrafficHistoryRequest(); request.ResponseGroup = responseGroup; request.Security = usecurity; request.Url = website; TrafficHistory browse = new TrafficHistory(); browse.Request = request; AWSAlexa alexa = new AWSAlexa(); TrafficHistoryResponse uresponse = alexa.TrafficHistory(browse); return uresponse.Response; } public CategoryListingsResponseResponse GetCategoryListingsResponse(string website, string action, string responseGroup, string path, bool recursive) { string timestamp = Helper.GetTimestamp(); string signature = Helper.MakeSignature(action + timestamp, privateKey); //Set the request security settings CategoryListingsRequestSecurity usecurity = new CategoryListingsRequestSecurity(); usecurity.AWSAccessKeyId = publicKey; usecurity.Signature = signature; usecurity.Timestamp = timestamp; CategoryListingsRequest request = new CategoryListingsRequest(); request.ResponseGroup = responseGroup; request.Security = usecurity; request.Path = path;//this.cmbListingPath.Text request.Recursive = recursive.ToString();//this.chkRecurse.Checked.ToString(); CategoryListings browse = new CategoryListings(); browse.Request = request; AWSAlexa alexa = new AWSAlexa(); CategoryListingsResponse uresponse = alexa.CategoryListings(browse); return uresponse.Response; } public CrawlResponseResponse GetCrawlResponse(string website, string action, string responseGroup) { string timestamp = Helper.GetTimestamp(); string signature = Helper.MakeSignature(action + timestamp, privateKey); //Set the request security settings CrawlRequestSecurity usecurity = new CrawlRequestSecurity(); usecurity.AWSAccessKeyId = publicKey; usecurity.Signature = signature; usecurity.Timestamp = timestamp; CrawlRequest request = new CrawlRequest(); request.ResponseGroup = responseGroup; request.Security = usecurity; request.Url = website; Crawl browse = new Crawl(); browse.Request = request; AWSAlexa alexa = new AWSAlexa(); CrawlResponse uresponse = alexa.Crawl(browse); return uresponse.Response; } #endregion 本文出自:亿恩科技【www.enkj.com】 |