Activity Stream
48,167 MEMBERS
6945 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Banned
    Website's:
    Seecure.me

    Default [PHP] GetAlexaTrafficRank

    [PHP] GetAlexaTrafficRank

    Pass through a domain without 'www' in "$domain". Read, Learn, Modify, Re-use.

    Example output:


    Code:
    Code: 
    <?php
    
    /**
     * This is simple description.
     * 
     * @author Vick Kumar <vickkumar2011@gmail.com>
     * @copyright Seecure.me, 2012
     * @version 1.0
     * @license http://creativecommons.org/licenses/by/3.0/legalcode 
     */
    
    function GetAlexaTrafficRank($domain)
    {
            $source = file_get_contents("http://www.alexa.com/siteinfo/$domain#");
            $regex = '/is ranked (.*) in/';
            preg_match($regex, $source, $match);
            $newresult = str_replace("number", "", $match[1]);
            return $newresult;
    }
    echo "Seecure.ME's Alexa Traffic Rank is: ".GetAlexaTrafficRank("seecure.me").".";
    ?>
    _Vick Reviewed by _Vick on . [PHP] GetAlexaTrafficRank GetAlexaTrafficRank Pass through a domain without 'www' in "$domain". Read, Learn, Modify, Re-use. Example output: http://screensnapr.com/e/uOxR3O.jpg Code: <?php Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    Elite.SO Defendos.com Motionite.com
    PHP Code: 
    <?php

    /**
     * This is simple description.
     * 
     * @author Vick Kumar <vickkumar2011@gmail.com>
     * @copyright Seecure.me, 2012
     * @version 1.0
     * @license http://creativecommons.org/licenses/by/3.0/legalcode 
     */
    $domain 'besthostingforums.com';

    function 
    GetAlexaTrafficRank($domain)
    {
            
    $source file_get_contents("http://www.alexa.com/siteinfo/$domain#");
            
    $regex '/is ranked (.*) in/';
            
    preg_match($regex$source$match);
            
    $newresult str_replace("number"""$match[1]);
            return 
    $newresult;
    }
    echo 
    $domain." 's Alexa Traffic Rank is: ".GetAlexaTrafficRank($domain).".";
    ?>
    Fixed

    Easier for them noobs.

    Defendos BETA3 Released! Thread - Official Website

  4.     
    #3
    Banned
    Website's:
    Seecure.me
    ^ Won't work due to $domain is passed via function, not set outside of function etc.

  5.     
    #4
    Member
    Website's:
    Elite.SO Defendos.com Motionite.com
    Yeah, but it will work if you have the $domain variable in your code.

    Goodjob btw

    Defendos BETA3 Released! Thread - Official Website

  6.     
    #5
    Member
    PHP Code: 
    function GetAlexaTrafficRank($domain) {
       
    $domain preg_replace('#(https?://)?(www\.)?#i','',$domain);
       ... 
    This should strip "http://", "https://", "www.", so you can pass almost any domain to the function.

  7.     
    #6
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    The Regex failed

    PHP Code: 
    <?php

    /**
     * This is simple description.
     * 
     * @author Vick Kumar <vickkumar2011@gmail.com>
     * @copyright Seecure.me, 2012
     * @version 1.0
     * @license http://creativecommons.org/licenses/by/3.0/legalcode 
     */

    function GetAlexaTrafficRank($domain)
    {
            
    $source file_get_contents("http://www.alexa.com/siteinfo/$domain#");
            
    $regex '/is ranked (.*) in/';
            
    preg_match($regex$source$match);
            
    $newresult str_replace("number"""$match[1]);
            return 
    $newresult;
    }
    echo 
    "KWWHunction's Alexa Traffic Rank is: ".GetAlexaTrafficRank("besthostingforums.com").".";
    ?>
    Try it yourself and heres the result:


    Fix the regex

  8.     
    #7
    Member
    http://www.alexa.com/siteinfo/besthostingforums.com
    The rank is calculated using a combination of average daily visitors to
    besthostingforums.com and pageviews on besthostingforums.com over the past 3 months. The site with the highest combination of visitors and pageviews is ranked #1.
    That's why the regex fails.
    Here's a fix:
    PHP Code: 
    function GetAlexaTrafficRank($domain)
    {
            
    $source file_get_contents("http://www.alexa.com/siteinfo/$domain#");
            
    $regex '#([0-9,]+)\s*</div>\s*<div class="label">Global Rank#';
            
    preg_match($regex$source$match);
            
    $newresult str_replace("number"""$match[1]);
            return 
    $newresult;
    }
    echo 
    "KWWHunction's Alexa Traffic Rank is: ".GetAlexaTrafficRank("besthostingforums.com")."."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

BE SOCIAL