Jump to content

Grabbing Hiscores


blakdragon39

Recommended Posts

I've got spring break coming up next week and I wanna mess around trying to create an awesome slayer calculator. :D The only languages I really know are Java and procedural C++, but I'm definitely willing to learn a different one, if there's a more practical one for doing this. :)

 

So anyways, what I want to do is be able to input the name of a user and have it return a skill's level, experience, etc. What language would be best for this? Is there maybe a tutorial that someone could point me too? I don't really have any idea of where to start!

Blakdragon39.png
Link to comment
Share on other sites

You can do it with any language really. You basically have to generate the url based on a specifc username.

 

Jagex makes the lite hiscores available for this purpose: http://hiscore.runescape.com/index_lite.ws?player=USERNAME HERE. Replace the "username here" with whatever username you want to search for and then read in the data found on that page (split by commas).

polvCwJ.gif
"It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

Link to comment
Share on other sites

I think I looked at that C# one, but it didn't look quite like what I was looking for. It was meant to grab the ENTIRE high scores I believe, and I just want one.

 

You can do it with any language really. You basically have to generate the url based on a specifc username.

 

Jagex makes the lite hiscores available for this purpose: http://hiscore.runes...player=USERNAME HERE. Replace the "username here" with whatever username you want to search for and then read in the data found on that page (split by commas).

This is definitely helpful, I'll have to see where I can go with this, thanks. :D

Blakdragon39.png
Link to comment
Share on other sites

Using Java, all I had to do was make a URL and then a BufferedReader that reads from the URL as a stream, and I'm able to access everything from the page. I'm still looking at all those links however, as I'm interested as to how much farther I could go than just reading in simple text. xD I don't really know much about sockets/servers/clients or any of that stuff so hopefully none of this will be too over my head. ^^

Blakdragon39.png
Link to comment
Share on other sites

So I went searching through my old code and I found a java implementation,

 

http://pastebin.com/Zn9qfvVQ

 

import java.net.*;
import java.io.*;
import java.util.Vector;

public class hiscores
{
   public static final String searchURL = "http://hiscore.runescape.com/index_lite.ws?player=";
   public static final String[] skillName = {"Overall", "Attack", "Defence", "Strength",
                                   "Constitution", "Ranged", "Prayer", "Magic",
                                   "Cooking", "Woodcutting", "Fletching", "Fishing",
                                   "Firemaking", "Crafting", "Smithing", "Mining",
                                   "Herblore", "Agility", "Thieving", "Slayer",
                                   "Farming", "Runecrafting", "Hunter", "Construction",
                                   "Summoning", "Dungeoneering", "Duel Tournament",
                                   "Bounty Hunters", "Bounty Hunter Rogues",
                                   "Fist of Guthix", "Mobilising Armies",
                                   "B.A Attackers", "B.A Defenders", "B.A Collectors",
                                   "B.A Healers", "Castle Wars Games", "Conquest"};
   public static final String[] skillDataName = {"Rank", "Level", "Experience"};
   public static final int expVSize = skillName.length;

   public static void main(String[] args)
   {
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String keyboard = "";

       while(true)
       {
           System.out.print("Enter rs name: ");
           try
           {
               keyboard = br.readLine();
               if(keyboard.compareTo("`exit") == 0)
                   break;
           }
           catch(Exception e)
           {
               System.out.println("Threw a " + e.getClass() + " with message " + e.getMessage());
           }
           System.out.println();

           try
           {
               System.out.println("Looking up hiscores . . .");
               Vector stats = getHiscores(keyboard);
               System.out.println("Found player!");
               System.out.print(rHiscoresToString(stats));
           }
           catch(FileNotFoundException e)
           {
               System.out.println("User not found.");
           }
           catch(Exception e)
           {
               System.out.println("Threw a " + e.getClass() + " with message " + e.getMessage());
           }
       }
   }

   public static String rHiscoresToString(Vector data)
   {
       String formatted = "";
       for(int i = 0; i < expVSize; i++)
       {
           String[] get = (String[])data.get(i);

           formatted = formatted + "[" + skillName[i] + "] ";
           for(int i2 = 0; i2 < get.length; i2++)
           {
               formatted = formatted + skillDataName[i2] + ": " + get[i2] + " || ";
           }

           formatted = formatted + "\n";
       }

       return formatted;
   }

   public static Vector getHiscores(String rsname) throws Exception
   {
       Vector data = new Vector(expVSize);
       URL resultsURL = new URL(searchURL + rsname);
       BufferedReader resultsBuffer = new BufferedReader(new InputStreamReader(resultsURL.openStream()));

       String current = "";
       while((current = resultsBuffer.readLine()) != null)
       {
           data.add(current.split(","));
       }

       resultsBuffer.close();
       return data;
   }
}

 

Terrible code fyi, just a rapid code. Need to watch out for expected vector size being greater than actual, causes out of bounds although unlikely. Should add a comparison

Edited by Markup
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.