为网站构建自己的Aleax查询服务
原创 2015-10-26 13:41:41Alexa网站排名被业界普通的认可,排名数据会经常地被引用,每次都在网站上查询就会显得不方便。Amazon提供的Alexa的API,让开发者可以构建自己的Alexa查询的应用。
前言
每个网站的站长都会想尽办法提升网站的流量,从而获得更高的广告收入。那么评判一个网站好坏的标准,如Google的PR(PageRank),百度权重等。从PV(Page View)流量的角度,一个非常重要指标就是Alexa网站排名。
同全球的网站相比,你就能了解到自己网站的get="_blank">位置,让我们先挤进全球前10万的排名吧,不然都不好意思跟同行说,“自己有一个网站”。
目录
1. Alexa介绍
2. 用Node开发Alexa服务
3. 作者介绍
1. Alexa介绍
Alexa ()是一家发布世界网站排名的网站,以搜索引擎起家的Alexa创建于1996年4月(美国),目的是让互联网网友在分享虚拟世界资源的同时,更多地参与互联网资源的组织。Alexa每天在网上搜集超过1TB的信息,不仅给出多达几十亿的网址链接,而且为其中的每一个网站进行了排名。可以说,Alexa是当前拥有URL数量最庞大,排名信息发布最详尽的网站。
1999年,Alexa被美国电子商务旗舰企业“亚马逊”收购,成为后者的全资子公司。2002年春,Alexa放弃了自己的搜索引擎,转而与Google合作。
Alexa提供了网站流量统计的服务,对全球有域名的网站进行流量记录。也就是说,只要你申请了域名,在Alexa中就可以查询到你的网站的排名。Alexa的网站排名是按照每个特定网站的被浏览率进行排名的。浏览率越大,排名越靠前。
通常情况,如果你的域名刚刚注册,排名在1千万以上;接下来,你每天都经心运营网站,小有起色时,排名会进入前1百万;然后,你继续发布优质内容,坚持了一段时间,排名会升至前50万;当你的网站在某一领域小有名气时,排名可以到达10万,如粉丝日志122616(2015-10-25),这时就会有广告主愿意来投放广告了;如果你做的是以盈利为目的的网站,那么你需要再加油,进入到前1万,这个时候你的流量已经可以为你带来生意了;如果能做的更好,排名进入前2000,像雪球排名到2109(2015-10-25),那么你将会有一个很高的估值了;如果能赶上一个天大的机遇,你的网站排名到了前100,那么你的网站将给你带来上市公司的价值,如京东105(2015-10-25);如果你是天才型的CEO,网站进了前10名,那么你将会成为一个产业的***,甚至是某个区域的首富,如百度4(2015-10-25)。
站长们,加油!
2. 用Node开发Alexa服务
2.1 Alexa开放API
Alexa网站排名被业界普通的认可,排名数据会经常地被引用,每次都在网站上查询就会显得不方便。Amazon提供的Alexa的API,让开发者可以构建自己的Alexa查询的应用。
Alexa有2个主要的数据API服务。
• Alexa Web Information Service,查询单个网站的排名信息
• Alexa Top Sites,查询网站的综合排名
通常情况,只需要调用UrlInfo数据接口,就可以获得网站的流量数据了。当然,这个接口的定义,并不像我之前想象的那么好用,而且开放出来的数据有限。
UrlInfo接口的API。
官方提供了多语言的SDK工具包,我觉得还是Node.js最方便。我构建的一个Alexa数据查询服务,
2.2 创建AWS的API密钥
我们在使用AWS的API之前,需要先创建密钥,类似于OAuth2的访问的机制。
1. 注册AWS账号,请大家自己完成。注册
2. 进入AWS账号管理控制台,控制台
3. 从控制台选择“安全证书”
4. 创建访问密钥(访问密钥 ID 和私有访问密钥)
我们一会写程序的时候,需要输入创建的访问密钥 ID 和私有访问密钥。
2.3 用Node开发Alexa服务
接下来,介绍用Node构建一个Alexa的项目。
我的系统环境
• Win10 64bit
• Node v0.12.3
创建项目
~ D:\workspace\nodejs>mkdir nodejs-alexa && cd nodejs-alexa
新建Node项目配置文件:package.json
~ vi package.json{"name": "alexa-demo","version": "0.0.1","description": "alexa web demo","license": "MIT","dependencies": {"awis": "0.0.8"}}
安装awis包
~ D:\workspace\nodejs\nodejs-alexa>npm installnpm WARN package.json [emailprotected] No repository field.npm WARN package.json [emailprotected] No README>[emailprotected] node_modules\alexarank├── [emailprotected] ([emailprotected], [emailprotected])└── [emailprotected] ([emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected])[emailprotected] node_modules\awis├── [emailprotected] ([emailprotected], [emailprotected])├── [emailprotected]└── [emailprotected] ([emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected], [emailprotected])
新建文件alexa.js,调用AWS Alexa网站排名API。
~ vi alexa.js// 定义AWS密钥var key = 'xxxxxxxxxxxxxxx';var sercet = 'xxxxxxxxxxxxxxx';// 创建awis实例化对象var awis = require('awis');var client = awis({key: key,secret: sercet});// 调用UrlInfo接口console.log("=============UrlInfo=================");client({'Action': 'UrlInfo',//UrlInfo接口'Url': 'fens.me',//查询的网站'ResponseGroup': 'TrafficData,ContentData'//需要的数据组}, function (err,?>1e7d8406-4b62-3460-27fb-325fc3dc3e85 fens.me 粉丝日志 跨界的IT博客|Hadoop家族, R, RHadoop, Nodejs, AngularJS, NoSQL, IT金融 982 70 198 fens.me 122616 3 122616 +28849 110056 +25785 12.5 -24.68% 0.27 -24.84% 194189 43945 1.9 0% 1 102621 -30257 95663 -20326 15 +20% 0.37 +60% 153976 -69981 2.2 +30% 7 114709 +32390 103552 +27312 14 -28.59% 0.3 -37.28% 188124 58655 2.0 -12.11% 1 74860 -93163 70563 -54001 20 +60% 0.6 +300% 111541 -210757 2 +100% blog.fens.me 1 99.19% 99.64% 2.2 OTHER 1 0 0.36% 0 Success
除了UrlInfo接口还有几个接口可以使用。
TrafficHistory接口
console.log("=============TrafficHistory=================");client({'Action': 'TrafficHistory','Url': 'fens.me','ResponseGroup': 'History'}, function (err, res) {if(err) console.log(err);console.log(res.trafficHistory);console.log(res.trafficHistory.range);console.log(res.trafficHistory.site);console.log(res.trafficHistory.start);console.log(res.trafficHistory.historicalData);console.log(res.trafficHistory.historicalData.data);console.log(res.trafficHistory.historicalData.data.length);res.trafficHistory.historicalData.data.forEach(function (item) {console.log(item.date);console.log(item.pageViews);console.log(item.rank);console.log(item.reach);});});
运行程序
~ D:\workspace\nodejs\nodejs-alexa>node alexa.js=============TrafficHistory================={ range: '31',site: 'fens.me',start: '2015-09-23',historicalData:{Action': 'SitesLinkingIn','Url': 'fens.me','ResponseGroup': 'SitesLinkingIn'}, function (err,Action': 'CategoryBrowse','Url': 'fens.me','Path': 'Top/china','ResponseGroup': 'LanguageCategories'}, function (err,>
什么是Alexa排名
整个互联网现在一共存在1亿多个网站,平均来讲每10个网民中,有一个人拥有网站。 但,网站和网站是有很大区别的,不能说你有网站,我也有网站,咱们就水平相当。 阿里巴巴网站和seo十万个为什么网站,显然水平不相当。 那么,有没有那么一个标准来衡量网站的水平呢? 美国的一群年轻人想到了一个办法:采用某个网站的用户使用数来表征一个网站的价值。 具体办法简单来讲是这样的:在浏览器中植入一个叫做alexa的插件,用于向alexa数据库反馈该浏览器正加载的网页。 每三个月,对这个alexa数据库进行一次网页浏览量的统计和排名。 ——这就是传说中的alexa排名。 但好像很少人安装alexa插件呀?略微懂数学的人就知道,要计算alexa排名其实只要知道安装alexa插件的网民比例就够了,无需每个人都要安装alexa。 也正是为此,alexa排名对于流量很低的站点,其实是非常不精确的。 alexa排名有什么实际用途? 对于一般站点:个人站点、企业站点、网店等,alexa排名没有任何实际用途。 排名100万与50万其实没有本质的差别。 但,对于纯网络公司,其主站点的alexa排名是非常重要的。 排名1万与5000那是天大的区别。 这对于他们的对外宣传、网站价值,是金子般的珍贵。 对于我们做seo的,考虑alexa排名纯粹是在浪费时间。 日ip流量在1万以内的站长也不要在这方面花时间。
如何向Alexa 提交网站信息
朋友,这很容易的,但Alexa注册要求验证网站所有权,建议你就近找信得过、懂英文的朋友帮忙更稳妥一些(因为这不难,只要登录Alexa官方网站,注册用户后不断根据Alexa网页提示填写、操作就是,但却涉及一个网站的核心机密,建议不要随便在网上找人帮忙,因为这对于网站未来的安全性始终是一个隐患)。 而且,朋友,我说句掏心窝子的话,如果你不是英文网站,除非你面对中国大陆用户的中文网站Alexa排名能进入1万名以内,否则Alexa排名没有什么实际意义,还是把精力集中于怎么样做好网站内容,做好网络、谷歌搜索引擎的优化。 我原来那个网站靠刷Alexa排名,排名最好时22万名,但由于找不到为服务对象所能接受的赢利模式,最后不得不关闭了,所以,朋友,我认为Alexa排名对于国内中小网站没有多大的实际意义,朋友还不如试着将自己的网站提交给亚马逊目录,虽然收录很不容易,但如果收录了,各个搜索引擎收录量都会大大提升,这对于你的网站会有着更大的实质意义。
我要做个用eclipse来实现ip查询功能
如何用Java获得一个域名的IP地址呢?提供这个功能的类叫做。 我们假设现在有这样一个域名,他用一个静态的 getByName来重新获得一个InetAddress,然后得到能够读出的IP地址。 下面的代码是很基本的命令行。 import ; import ; public class NsLookup { static public void main(String[] args) { try { InetAddress address = (args[0]); (args[0]+ : +()); } catch(UnknownHostException uhe) { (Unable to find: +args[0]); } } } InetAddress也能够通过使用getAddress()来获得IP地址,但是他的返回值是个4个字节的数组。 因此尽管getAddress()在获得IP方面是有用的,但却不适于用来输出。 上面的命令的输出结果看起来就是这样: bash$ java : 192.18.97.241 有时一个域名会包含不止一个IP地址,比如微软的Web服务器,这是为了保持负载平衡。 InetAddress提供了一种能够得到一个域名的任何IP地址的方法。 让我们来考虑以下代码: import ; import ; public class NsLookup { static public void main(String[] args) { try { String name = args[0]; InetAddress[] addresses = (name); for(int i=0; i<; i++) { (name+[+i+] : +()); } } catch(UnknownHostException uhe) { (Unable to find: +args[0]); } } } 对于,将会输出: bash$ java [0]: 192.18.97.241 然而,对于,将会输出: bash$ javad code/ [0]: 207.46.230.218 [1]: 207.46.197.101 [2]: 207.46.230.229 [3]: 207.46.197.113 [4]: 207.46.230.219 [5]: 207.46.230.220 [6]: 207.46.197.102 由于InetAddress,localhost必须要特别处理。 假如字符串“localhost”直接进入NsLookup程式的原始版本,就会得到以下相当无用的结果: bash$ java localhost: 127.0.0.1 我们能够手动寻找本地地址: try { InetAddress localhost = (); (localhost: +()); (localhost: +()); } catch(UnknownHostException uhe) { (Localhost not seeable. Something is odd. ); } 这里是个输出的例子: localhost: 192.168.13.15 localhost: crab 本地主机的域名并没有返回完整的该机器的域名,这是因为他取决于该机器的配置。 最后,InetAddress可能会被用来将IP地址转变为这些地址的域名,这对于分析Web日志是很有用的。 InetAddress使得研发者们能够轻松的和域名、IP地址打交道,并且使他们能够不必和DNS服务器进行交互。














发表评论