Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GE Data (get price etc. by item name) no external libraries required

Featured Replies

If I set references to the table with all of the data to null after pulling the information from it, will it free all allocated memory?

 

map.clear()

 

please.

  • 4 weeks later...

How do you change for average buy and average sell

soz double post

Edited by RedFr3sh

  • Author

How do you change for average buy and average sell

soz double post

 

The data is retrieved in the format:

{"overall":369,"buying":372,"buyingQuantity":108551,"selling":367,"sellingQuantity":121543}

Using a URL such as: http://api.rsbuddy.com/grandExchange?a=guidePrice&i=1515

 

 

The following method retrieves the "overall" value:

private Optional<Integer> getRSBuddyPrice(){
    try {
        URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id);
        URLConnection con = url.openConnection();
        con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
        con.setUseCaches(true);
        BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String json = br.readLine();
        br.close();
        Matcher matcher = Pattern.compile("\"overall\"\\s*:\\s*(\\d*)").matcher(json);
        return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty();
    } catch(Exception e){
        e.printStackTrace();
    }
    return Optional.empty();
}

If you wanted to retrieve all of these data items, you can just alter this method to instead return a Map<String, Integer>, and instead of just doing:

Matcher matcher = Pattern.compile("\"overall\"\\s*:\\s*(\\d*)").matcher(json);
return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty();

Which gets the "overall" value, you can do this for "buying", "selling" etc. and add it to the Map.

 

I will write this up when I get home if you aren't sure how to do it.

  • 3 weeks later...

These snippets are wonderful. I was just getting around to writing a fighter and needed to write in my loot calculator. Thanks so much for sharing this. :)

  • 2 weeks later...

sigh perhaps you should read up on the Java Garbage Collector then.

 

If you are really concerned about memory usage, then perhaps you should use a profiler to see how much memory, and where the memory is being used.

 

It isn't really a concern though. It's just a Map containing a few objects..

How can i get only price?

  • 1 month later...
  • 3 weeks later...

Any idea why this worked perfectly for me for a couple of first times and started not to find the items I'm looking for? Even tried by replacing the getRSBuddyPrice() method with getOSRScurrentPrice().

  • Author

Any idea why this worked perfectly for me for a couple of first times and started not to find the items I'm looking for? Even tried by replacing the getRSBuddyPrice() method with getOSRScurrentPrice().

 

I noticed there was a slight error in one of the regex patterns, it may have been causing issues for you. I have fixed it in the original post.

  • 4 weeks later...

How can i get only price?

Map<String, ExchangeItem> exchangeItems = new RSExchange().getExchangeItems("Your item");
exchangeItems.get("Your item").getPrice();
Map<String, ExchangeItem> exchangeItems = new RSExchange().getExchangeItems("Your item");
exchangeItems.get("Your item").getPrice();

i got it working long time ago, but anyways thanks. :)

If I may ask, is there a reason why java.util.Optional is unresolveable? Maybe it's just me?

  • Author

If I may ask, is there a reason why java.util.Optional is unresolveable? Maybe it's just me?

 

Make sure the language level of your IDE is set to Java 8, because Optionals were a new feature introduced in Java 8.

Make sure the language level of your IDE is set to Java 8, because Optionals were a new feature introduced in Java 8.

 

Aha, that explains that then. I was still using 1.7.0. Thanks!

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.