• Log in or sign up for an account here: https://www.sythe.org/login

Help With Java, GE. - Robotz MTA Related.

Morphis

Apprentice
Banned
Joined
Aug 2, 2008
Sythe Gold
0
Messages
734
Help With Java, GE. - Robotz MTA Related.
Well I am working on something that involves Robotz Mage Training Arena Bot, and I need some help.

I need help on how to extract the prices of items from the Grand Exchange Page on Runescape.
For example, how could I get these values the min, market, and max of this item. - http://itemdb-rs.runescape.com/viewitem.ws?obj=9143

Now you might ask what is the point in this? Well I want to make my program auto update the price by connecting to the items webpage and getting the min med and max values. Any help would be greatly appreciated.
 
Help With Java, GE. - Robotz MTA Related.
Are you looking to find the item price by it's ID, or by it's name?
 
Help With Java, GE. - Robotz MTA Related.
I have the webpage I want to get the price from, i just need the program to be able to grab it.
 
Help With Java, GE. - Robotz MTA Related.
Here's a function that'll return the prices in a String array.

Code:
public static String[] getPrice(String urls) {
	try {
		String page = new String();
		URL url = new URL(urls);
		InputStream in = url.openStream();
		BufferedInputStream bufIn = new BufferedInputStream(in);
		
		for(;;) {
			int data = bufIn.read();
			
			if (data == -1)
				break;
			else
				page += (char)data;
		}
		bufIn.close();
		in.close();
		String[] price = new String[3];
		String[] array;
		String splitter = "price:</b> ";
			
		array = page.split(splitter);
		splitter = "</span>";
		for (int i = 1; i <= 3; i++)
				price[i - 1] = array[i].split(splitter)[0].replaceFirst("\n", "");
		
		return price;
	} catch (MalformedURLException e) {
		System.out.println(e.toString());
		String error = "Unable to fetch price";
		return new String[] { error, error, error };
	} catch (IOException e) {
		System.out.println(e.toString());
		String error = "Unable to fetch price";
		return new String[] { error, error, error };
	}
}

An example of how to use this would be:
Code:
		String[] prices = getPrice("http://itemdb-rs.runescape.com/viewitem.ws?obj=9143");
		for (int i = 0; i < 3; i++)
			System.out.println(prices[i]);

Output:
Code:
184
193
202
 
Help With Java, GE. - Robotz MTA Related.
Here's a function that'll return the prices in a String array.

Code:
public static String[] getPrice(String urls) {
	try {
		String page = new String();
		URL url = new URL(urls);
		InputStream in = url.openStream();
		BufferedInputStream bufIn = new BufferedInputStream(in);
		
		for(;;) {
			int data = bufIn.read();
			
			if (data == -1)
				break;
			else
				page += (char)data;
		}
		bufIn.close();
		in.close();
		String[] price = new String[3];
		String[] array;
		String splitter = "price:</b> ";
			
		array = page.split(splitter);
		splitter = "</span>";
		for (int i = 1; i <= 3; i++)
				price[i - 1] = array[i].split(splitter)[0].replaceFirst("\n", "");
		
		return price;
	} catch (MalformedURLException e) {
		System.out.println(e.toString());
		String error = "Unable to fetch price";
		return new String[] { error, error, error };
	} catch (IOException e) {
		System.out.println(e.toString());
		String error = "Unable to fetch price";
		return new String[] { error, error, error };
	}
}

An example of how to use this would be:
Code:
		String[] prices = getPrice("http://itemdb-rs.runescape.com/viewitem.ws?obj=9143");
		for (int i = 0; i < 3; i++)
			System.out.println(prices[i]);

Output:
Code:
184
193
202

Wow thank you so much for this, I just needed a method but this, this is just amazing. You have no idea how much you helped me.
 
Runescape Gamblingrunescape gambling
Back
Top