alexa排名

The most well known online website popularity measuring stick appears to be Alexa. Alexa provides a wealth of information on a given website, most notably:

最知名的在线网站受欢迎程度衡量指标似乎是Alexa 。 Alexa在给定的网站上提供了大量信息,最值得注意的是:

  • Popularity rank (the most important one)

    人气排名(最重要的排名)

  • Reach达到
  • In-links内联
  • Speed速度

Alexa provides this information in many useful formats, including XML. Using the XML provided by Alexa, we can gain access to Alexa information within our pages. I've created a PHP class to make fetching Alexa data free, quick, and easy. The class comes in a PHP4 version and a PHP5 version.

Alexa以许多有用的格式(包括XML)提供此信息。 使用Alexa提供的XML,我们可以访问页面中的Alexa信息。 我创建了一个PHP类,以免费,快速,轻松地获取Alexa数据。 该类有PHP4版本和PHP5版本。

代码-PHP4版本 (The Code - PHP4 Version)

/* the alexa rank class */
class alexa
{
/* initial vars */
var $xml;
var $values;
var $alexa_address;
/* the constructor */
function alexa($alexa_address,$domain)
{
$this->alexa_address = $alexa_address;
$this->xml = $this->get_data($domain);
$this->set();
}
/* gets the xml data from Alexa */
function get_data($domain)
{
$url = $this->alexa_address.'http://'.$domain;
$xml = file_get_contents($url);
return $xml;
}
/* set values in the XML that we want */
function set()
{
$this->values['rank'] = (preg_match('/POPULARITY URL="[a-z0-9\\-\\.\\/]{1,}" TEXT="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
$this->values['reach'] = (preg_match('/REACH RANK="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
$this->values['linksin'] = (preg_match('/LINKSIN NUM="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
}
/* returns the requested value */
function get($value)
{
return (isset($this->values[$value]) ? $this->values[$value] : '"'.$value.'" does not exist.');
}
}

代码-PHP5版本 (The Code - PHP5 Version)

/* the alexa rank class */
class alexa
{
/* initial vars */
var $xml;
var $values;
var $alexa_address;
/* the constructor */
function alexa($alexa_address,$domain)
{
$this->alexa_address = $alexa_address;
$this->xml = $this->get_data($domain);
$this->set();
}
/* gets the xml data from Alexa */
function get_data($domain)
{
$url = $this->alexa_address.'http://'.$domain;
$xml = simplexml_load_file($url) or die('Cannot retrieve feed');
return $xml;
}
/* set values in the XML that we want */
function set()
{
$this->values['rank'] = ($this->xml->SD->POPULARITY['TEXT'] ? number_format($this->xml->SD->POPULARITY['TEXT']) : 0);
$this->values['reach'] = ($this->xml->SD->REACH['RANK'] ? number_format($this->xml->SD->REACH['RANK']) : 0);
$this->values['linksin'] = ($this->xml->SD->LINKSIN['NUM'] ? number_format($this->xml->SD->LINKSIN['NUM']) : 0);
}
/* returns the requested value */
function get($value)
{
return (isset($this->values[$value]) ? $this->values[$value] : '"'.$value.'" does not exist.');
}
}

使用cURL (Using cURL)

If you'd rather use the cURL library, you can simply modify the get_data() function:

如果您想使用cURL库,则只需修改get_data()函数:

/* gets the XML data from Alexa */
function get_data($domain)
{
$url = $this->alexa_address.'http://'.$domain;
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$xml = curl_exec($ch);
curl_close($ch);
return $xml;
}

用法 (The Usage)

Provide two paramenters: the path to the XML file (minus the domain) and the domain.

提供两个参数:XML文件的路径(减去域)和域。

/* retrieve & display rank */
$alexa_connector = new alexa('http://alexa.com/xml/dad?url=','digg.com'); // domain only!
echo 'Rank :: '.$alexa_connector->get('rank'); // returns 118
echo '';
echo 'Reach :: '.$alexa_connector->get('reach'); // returns 95
echo '';
echo 'Links In :: '.$alexa_connector->get('linksin'); // returns 34,414

Do you have any suggestions for this class?

您对此课程有什么建议吗?

翻译自: https://davidwalsh.name/php-alexa-rank-fetcher-xml

alexa排名


http://www.taodudu.cc/news/show-5838512.html

相关文章:

  • 2019年最新alexa排名前100w的域名
  • 什么是ALEXA排名
  • ALEXA排名机制(转)
  • tp6.0文档解析(简介+安装)
  • tp5+ barcode 生成条形码
  • tp5 mysql缓存_tp5.0 SHOW COLUMNS FROM 生成数据表字段缓存
  • php tp框架调用m层,TP学习笔记一(tp的目录结构 , tp的输出方式)
  • xL2TP安装笔记
  • tp5能运行在php7吗,tp 5.0 php 7.0 nginx 配置
  • TP5验证码生成及验证
  • tp3 跨域_tp6 通过全局中间件 解决跨域问题
  • TP5框架
  • 学习tp5
  • tp5 Loader.php,TP5代码学习笔记:Loader
  • IPv6 DHCP
  • OSPF开放式最短路径优先
  • 活美课堂 活美教师 活美学生
  • 淘宝旗舰店
  • 怎么给09淘宝店增加附加价值
  • 电子签名?玩具罢了!(web前端)
  • 毕设-基于单片机的声光电子琴
  • 西工大电子服务系统设计复习总结
  • python list每个重复元素保留一次,python 列表(list)去除重复的元素总结
  • 电子学会青少年软件编程 Python编程等级考试二级真题解析(选择题)2022年3月
  • STM32掌机教程6,电子琴
  • 人员进入空间
  • 地球物理学专业计算机,中国矿业大学(北京)
  • 在什么情况下“100-1=0”?
  • 如何引爆用户增长:驱动用户增长的7大战略要素
  • “区块链+社媒”是埋骨地 微博、Telegram为何仍要前赴后继

alexa排名_PHP Alexa排名提取器类相关推荐

  1. Python即时网络爬虫项目: 内容提取器的定义(Python2.7版本)

    1. 项目背景 在Python即时网络爬虫项目启动说明中我们讨论一个数字:程序员浪费在调测内容提取规则上的时间太多了(见上图),从而我们发起了这个项目,把程序员从繁琐的调测规则中解放出来,投入到更高端 ...

  2. Scrapy-Link Extractors(链接提取器)

    Link Extractors 中文文档:https://scrapy-chs.readthedocs.io/zh_CN/1.0/topics/link-extractors.html Link Ex ...

  3. python爬虫程序的流程图_Python即时网络爬虫项目: 内容提取器的定义(Python2.7版本)...

    ###1. 项目背景 在Python即时网络爬虫项目启动说明中我们讨论一个数字:程序员浪费在调测内容提取规则上的时间太多了(见上图),从而我们发起了这个项目,把程序员从繁琐的调测规则中解放出来,投入到 ...

  4. python网络爬虫的项目背景_第四章 Python即时网络爬虫项目: 内容提取器的定义

    1. 项目背景 在python即时网络爬虫项目启动说明中我们讨论一个数字:程序员浪费在调测内容提取规则上的时间,从而我们发起了这个项目,把程序员从繁琐的调测规则中解放出来,投入到更高端的数据处理工作中 ...

  5. alexa api php,Alexa的XML API获取网站的Alexa排名的PHP示例代码

    Alexa的XML API获取网站的Alexa排名的PHP示例代码 分类:应用接口| 发布:佚名| 查看: | 发表时间:2014/8/19 我们通会用Alexa的网站(或其它站长工具网站)来栓查我们 ...

  6. 通过Alexa API获取Alexa排名

    我们通会用Alexa的网站(或其它站长工具网站)来栓查我们的网​站流量排名,这样就必须去那些网站.实际上,可以通过Alexa XML API 获取网站的Alexa相关的数据(XML格式的),再使用XM ...

  7. 干货:排名前 16 的 Java 工具类!

    2019独角兽企业重金招聘Python工程师标准>>> 干货:排名前 16 的 Java 工具类!   在Java中,工具类定义了一组公共方法,这篇文章将介绍Java中使用最频繁及最 ...

  8. java 文本工具类_干货:排名前16的Java工具类

    原标题:干货:排名前16的Java工具类 作者丨Java技术栈 https://www.jianshu.com/p/9e937d178203 在Java中,工具类定义了一组公共方法,这篇文章将介绍Ja ...

  9. Scala 入门3(类、Trait、模式匹配、正则、异常、提取器、IO)

    文章目录 1. 类和对象 2. Trait 3. 模式匹配 4. 正则 5. 异常处理 6. 提取器 7. 文件 IO 学自 https://www.runoob.com/scala/scala-tu ...

最新文章

  1. SCCM 2012 R2---安装SCCM 2012 R2
  2. 管理的最高境界:残缺中的和谐
  3. STL之七:STL各种容器的使用时机详解
  4. Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA
  5. ab flash player 8_FLASH 质子治疗的技术挑战
  6. canva画图 图片居中裁剪_css实现不定宽高的图片img居中裁剪_类似微信朋友圈图片效果...
  7. java 将换行代替_Java批量将文件中的段落替换成空格,根据指定分隔符换行(SQL示例)...
  8. python组件化软件github_GitHub - 872409/wepy: 小程序组件化开发框架
  9. MAC 电脑里面的“其他”文件是什么占用了
  10. CTP: 为什么报网络原因发送失败,但连接却成功?
  11. STM32F407——串口通信
  12. cmd xcopy 拷贝文件夹_cmd xcopy进行远程复制
  13. 今日头条的针锋相对让腾讯开始焦虑,天天快报能否占据一席之位?
  14. vue 上传视频到保利威视
  15. 牛客小白月赛21 I.I love you
  16. sonarqube8.9的pdf插件安装
  17. 百思不得姐php源码,微信小程序实战教程: 仿百思不得姐demo(附源码)
  18. 攻略:手把手教你如何看懂以太坊区块链浏览器(配图更清晰)
  19. 两个不同局域网电脑如何互相访问
  20. 状态寄存器传送指令 —— 访问(读写)CPSR寄存器

热门文章

  1. 有什么P图抠图的工具?几个步骤轻松处理
  2. 价格先升后降?薅不着的大额优惠券?造假销售额?Python帮你一一识破购物节套路
  3. 基于javaweb的财务管理系统(Mysql版)
  4. python socketio例子_Flask-SocketIO服务端安装及使用代码示例
  5. memmove详解及其模拟实现
  6. 委托(一)-委托概诉
  7. scipy.optimize.minimize参数
  8. d16 format on nv card
  9. FRR搭建简单BGP网络环境
  10. 新手上路系列 Web服务器搭建篇——IIS的搭建