English 中文(简体)
Fetching Alexa data [closed]
原标题:
  • 时间:2010-09-09 12:10:14
  •  标签:
  • php
  • alexa
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

How is it possible to get traffic data, sub domains data, country rank in percentage like in http://www.websiteoutlook.com/www.google.com?

最佳回答

NB: This approach doesn t work anymore. The endpoint simply returns "Ok", even for URLs which aren t assigned.

There is a free API (though I haven t been able to find any documentation for it anywhere).

http://data.alexa.com/data?cli=10&url=%YOUR_URL%

You can also query for more data the following way:

http://data.alexa.com/data?cli=10&dat=snbamz&url=%YOUR_URL%

All the letters in dat are the ones that determine which info you get. This dat string is the one I ve been able to find which seems to have more options. Also, cli changes the output completely, this option makes it return an XML with quite a lot of information.

EDIT: This API is the one used by the Alexa toolbar.

问题回答

A simple function to get the alexa rank

function alexa_rank($url){
    $xml = simplexml_load_file("http://data.alexa.com/data?cli=10&url=".$url);
    if(isset($xml->SD)):
        return $xml->SD->REACH->attributes();
    endif;
}

Works pretty well and free ;)

you can use this too

<?php
$url="http://stackoverflow.com/";
$xml = simplexml_load_file( http://data.alexa.com/data?cli=10&dat=snbamz&url= .$url);
$rank=isset($xml->SD[1]->POPULARITY)?$xml->SD[1]->POPULARITY->attributes()->TEXT:0;
$web=(string)$xml->SD[0]->attributes()->HOST;
echo $web." has Alexa Rank ".$rank;
?>

this will output it like

stackoverflow.com has Alexa Rank 55

Alexa have an API here. It s not free, though.

SimilarWeb has an API that exposes its traffic and ranking data. They also provide engagement metrics, referrals and domain categorization APIs, among others, so maybe it ll be good for you.

API - developer.similarweb.com

Usage for SimilarWeb Traffic API:

function api_traffic (URL, KEY) {

  var apiurl = "http://api.similarweb.com/Site/"
  + URL
  + "/v2/EstimatedTraffic?Format=JSON&UserKey=";
  + "KEY";


var fetch_visitors = UrlFetchApp.fetch(apiurl);
    Utilities.sleep(2000);

      var data = JSON.parse( fetch_visitors);
    return data.EstimatedVisitors;
    }

By using http://data.alexa.com/data?cli=10&url=%YOUR_URL% API you can have all data.

http://www.siteprice.org/api/ is the cheapest I think and easy to use.

$worthofwebsite= file_get_contents( http://www.siteprice.org/WorthApi.aspx?type=1&key=testkey&url=google.com ); 
echo "Website Worth: ".$worthofwebsite;




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签