Is it possible to get league (if ladder) - gold, silver, master, etc?

64 views
Skip to first unread message

Relige

unread,
Dec 24, 2011, 3:20:38 AM12/24/11
to phpsc2replay
Is it possible to get league (if ladder) - gold, silver, master,
etc???

I see some sites, that can get it from replay, for example: sc2rep.ru

spa...@sc2buddy.net

unread,
Dec 24, 2011, 4:53:57 AM12/24/11
to phpsc2replay
It is not stored in the replay itself. However the battlenet id and
character name are so these can be used to locate the players profile
on the battle.net website. From there its pretty straightforward to
extract the league from the html.

You can also use the sc2ranks api if your not comfortable doing that
but it is slow and normally very out of date.

Sabato Luca Guadagno

unread,
Aug 15, 2012, 10:04:39 AM8/15/12
to phpsc2...@googlegroups.com
I wanted to do the same thing and I resolved in this way:

<?php
function getPlayerLeague( $player_profileLink )
{
$DOM = new DOMDocument;
$DOM -> load( $player_profileLink );
$Elements = $DOM -> getElementsByTagName("*");
$Matched = array();

for( $i = 0; $i < $Elements -> length; $i++ ) 
{
if( $Elements -> item( $i ) -> attributes -> getNamedItem('class') -> nodeValue == 'league-name' ) 
{
$Matched[] = $Elements -> item( $i ) -> nodeValue;
}
}

return $Matched;
}

$game_realm    = $replay -> getRealm();
$player1_uid   = $players[1]['uid'];
$player1_uidIndex  = $players[1]['uidIndex'];
$player1_name  = $players[1]['name'];
$player1_profileLink = 'http://' . strtolower( $game_realm ) . '.battle.net/sc2/en/profile/' . $player1_uid . '/' . $player1_uidIndex . '/' . $player1_name . '/';
$player1_league = getPlayerLeague( $player1_profileLink );
?>

The function return an array where the first item is the league placement for 1v1 and the second one for team. From the last patch of Sc2, also the profile page of battle.net is changed. I need to investigate to get the current place in ladder 1v1, 2v2, 3v3 and 4v4. Hope this code can be usefull.

Sabato Luca Guadagno

unread,
Aug 16, 2012, 11:55:08 AM8/16/12
to phpsc2...@googlegroups.com
Ok I got the current 1v1 current league with:

function getPlayerLeague( $player_profileLink )
{
$DOM = new DOMDocument;
$DOM -> validateOnParse = true;
$DOM -> load( $player_profileLink );
$DOM -> preserveWhiteSpace = false;

$elements = $DOM -> getElementsByTagName("div");
$league = $elements -> item( 37 ) -> nodeValue;
$league = explode('Current League: ', $league );
return $league[1];
}

Il giorno sabato 24 dicembre 2011 09:20:38 UTC+1, Relige ha scritto:
Reply all
Reply to author
Forward
0 new messages