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.

RSBuddy/OSBuddy Exchange Price Lookup

Featured Replies

RSBuddy/OSBuddy Exchange has more accurate prices than Zybez for the most part.

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class PriceLookup {

	private static URLConnection con;
	private static InputStream is;
	private static InputStreamReader isr;
	private static BufferedReader br;

	private static String[] getData(int itemID) {
		try {
			URL url = new URL(
					"https://api.rsbuddy.com/grandExchange?a=guidePrice&i="
							+ itemID);
			con = url.openConnection();
			is = con.getInputStream();
			isr = new InputStreamReader(is);
			br = new BufferedReader(isr);
			String line = br.readLine();
			if (line != null) {
				return line.split(",");
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				} else if (isr != null) {
					isr.close();
				} else if (is != null) {
					is.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public static int getPrice(int itemID) {
		String[] data = getData(itemID);
		if (data != null && data.length == 3) {
			return Integer.parseInt(data[0].replaceAll("\\D", ""));
		}
		return 0;
	}

	public static int getAverageBuyOffer(int itemID) {
		String[] data = getData(itemID);
		if (data != null && data.length == 3) {
			return Integer.parseInt(data[1].replaceAll("\\D", ""));
		}
		return 0;
	}

	public static int getAverageSellOffer(int itemID) {
		String[] data = getData(itemID);
		if (data != null && data.length == 3) {
			return Integer.parseInt(data[2].replaceAll("\\D", ""));
		}
		return 0;
	}
} 

Dump of all the prices from March 27, 2015: http://pastebin.com/rQ5dk7mp

Edited by VladBots

nice.

close your streams and readers :|

 

 

Botre never satisfied sleep.png

 

Closing streams is programming 101.

 

If you dont close streams the buffer might not get flushed and you can get unexpected results.

Edited by Mysteryy

Closing streams is programming 101.

 

If you dont close streams the buffer might not get flushed and you can get unexpected results.

Oh...Im in my second semester of taking AP Comp Sci. Right now were working on inheritance :D

Oh...Im in my second semester of taking AP Comp Sci. Right now were working on inheritance biggrin.png

 

Are you using Big java for your book?

 

If you are, all the test are based off of a teacher copy of the book. I probably still have mine if you'd want to see it wink.png

Edited by twin 763

  • 4 weeks later...

The getPrice(), getAverageBuyOffer(), and getAverageSellOffer() methods are incorrect. String[] data will always be length 5, not length 3, so those methods will always return 0. For a simple fix, you may be able to change it to data.length==5 or just delete that parameter overall.

 

Also, it's fairly simple to split each index of the array by the ":" because the second half will be the price you want and the first half will be the description. For example, if you go to the link for iron ore (https://api.rsbuddy.com/grandExchange?a=guidePrice&i=440), you can see that the stream is:

 

{"overall":54,"buying":54,"buyingQuantity":125855,"selling":53,"sellingQuantity":103603}

 

Split up in the getData() method, It looks like this

 

String[] data = {

   ""overall":54",

   ""buying":54",

   ""buyingQuantity":125855",

   ""selling":53",

   ""sellingQuantity":103603"

}

 

If you split by colon, data[0].split(":") returns the array {""overall"", 54}. then, returning the parse of index 1 gives you 54.

 

Furthermore, the getter methods would return the wrong values, because data[2] is actually the buying quantity, not the selling price. It is important to change the return statement of getAverageSellOffer() to use data[3].

 

Here are the changes I made:

public static int getPrice(int itemID) {
	String[] data = getData(itemID);
	if (data != null && data.length == 5) {
		return Integer.parseInt(data[0].split(":")[1]);
	}
	return 0;
}

public static int getAverageBuyOffer(int itemID) {
	String[] data = getData(itemID);
	if (data != null && data.length == 5) {
		return Integer.parseInt(data[1].split(":")[1]);
	}
	return 0;
}

public static int getAverageSellOffer(int itemID) {
	String[] data = getData(itemID);
	if (data != null && data.length == 5) {
		return Integer.parseInt(data[3].split(":")[1]);
	}
	return 0;
}

Edited by bthebrave

-snip-

 

If you're still using this you should transfer over to the new Grand Exchange API itself by Alek.

Edited by 7331337

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.