How to read Runescape highscores?
If you are wondering how to utilize the new
But before we start I’d like to give a little background for the issue. As you might be aware Jagex made a step toward fan sites recently by introducing a new programmatic way to access
//———- PHP code to follow ————
$url = ‘http://hiscore.
$rs_string = file_get_contents($url);
preg_match_all(’#<table cellpadding=”3″ cellspacing=”0″ border=0>(.*?)</table>#s’, $rs_string, $stats);
$score = $stats[1][0];
$score = strip_tags($score);
//—————- end of PHP code ————————
Yuck! Then you would also parse the resulting table and account for things not featured in high scores for different players.
But now you can simply go to something like this:
http://hiscore.
and get all the stats you need! Plus this way will get you information about 30+ stats even when they are not shown in the high scores! Truly awesome. You can replace the ugly code shown above with this much more elegant and useful one (which works faster as well):
//———- PHP code to follow ————-
$cats_for_rs = array(’Overall’, ‘Attack’, ‘Defence’, ‘Strength’, ‘Hitpoints’,
‘Ranged’, ‘Prayer’, ‘Magic’, ‘Cooking’, ‘Woodcutting’, ‘Fletching’, ‘Fishing’, ‘Firemaking’, ‘Crafting’, ‘Smithing’, ‘Mining’, ‘Herblore’, ‘Agility’, ‘Thieving’, ‘Slayer’, ‘Farming’, Runecraft’, ‘Hunter’, ‘Construction’);
$user = “Vaskor”;
$txt = file_get_contents(’http://hiscore.
$score = array();
//explode using end of line as a delimiter
$data = explode (”\n”, $txt);
$ind = 0;
foreach ($data as $word) {
//key is a skill name
$key = $cats_for_rs[$ind];
//explode using a comma as a delimiter
$data_n = explode (”,”, $word);
$score[$key][”Rank”] = $data_n[0];
$score[$key][”Level”] = $data_n[1];
$score[$key][”Exp”] = $data_n[2];
$ind++;
}
//use level as a key for further processing as rank may be -1
//for 30+ stats not featured in high scores
//—————- end of PHP code ————————
That’s it.
However, there is a catch…
If the user does not have ANY skills in the high scores Jagex service returns ‘Page not found’ error and it brakes the whole thing down! Ouch…
They should have returned data in the same format if a person is not in the high scores… Well, they don’t… So, if you ask me, the new high scores service has only limited usability. In some cases it cannot be used because of this limitation.
I sent a suggestion to Jagex to fix the service behavior, but no response was given back to me. So for the time being I personally still use the old and ugly parsing method at Runewise and make a secondary calls to the Jagex service only to fill gaps for 30+ non-high score skills. Alas.
But again, the new service can be used in many other cases and it is definitely a step forward. I look forward additional services from Jagex which would allow fan sites to provide better, richer experiences to the players.
Posted by vrunewise (owner of Runewise and
Did You Enjoy this Post? Subscribe to Runescape Haven for Free Today!
9,560 Views










(9 votes, average: 4.33 out of 5)
September 10th, 2007 at 9:59 am
One correction. A few days ago Jagex reduced amount of the information the highscores service returns (silent non-announced change). Now the service returns information identical to what you see in the regular highscores. So no more info about 30+ non-highscore skills.
knifestorm Says:The code still works, just amount of data you get from it is less now.
September 19th, 2007 at 5:15 am
I just started to use this stuff. Couldn’t have done it without you. Thanks.
- Runescape Haven Says:September 24th, 2007 at 11:36 pm
[…] I wrote in the ‘How to read Runescape highscores?’ article, there is one API (Application Programming Interface). Specifically an API that allows […]
External APIs for Runescape? Please… - Runescape Haven Says:September 24th, 2007 at 11:38 pm
[…] I wrote in the ‘How to read Runescape highscores?’ article, there is one API (Application Programming Interface). Specifically an API that allows […]
snowbell84 Says:December 13th, 2007 at 9:38 pm
runescape is amazin i just started a new account i played 3 years but my lvl 80 ac was haked any ideas hw 2 get em back
Oveckin Says:i was in high scores on my old main
mel xx
February 27th, 2008 at 4:56 am
Parse Error line 2?
Oveckin Says:February 27th, 2008 at 5:02 am
sorry, problem is with PSPAD get ? instate ”
THanks for code.
RunescapeGod Says:June 2nd, 2008 at 1:45 am
Thanks for the code
RunescapeGod Says:June 14th, 2008 at 1:51 am
I made a grand exchange code check it out at my website
click on my name