Get download counts from Bukkitdev

Discussion in 'Bukkit Help' started by XmartinX, Jun 10, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    XmartinX

    Hi everyone. i'm trying to get the download count from Bukkitdev into a php variable. is this possible? if so, how do I do it?

    thanks

    Never mind, I figured it out...

    PHP:
    function getDownloads($slug) {
        
    $matches = array();
       
        
    $str file_get_contents("http://dev.bukkit.org/bukkit-mods/$slug");
       
        
    $start "<dd><span data-value=\"";
        
    $end "\">";
       
        
    $regex "/$start([a-zA-Z0-9_]*)$end/";
        
    preg_match_all($regex$str$matches);
       
        
    $array $matches[1];
        return 
    $array[0];
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
    alexander7567 likes this.
  2. Offline

    alexander7567

    Thanks, you saved me a lot of trouble! Most people don't bother to post the answer if they solve it themselves, so thanks!
     
Thread Status:
Not open for further replies.

Share This Page