Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Zybez Price Fetcher


    Eliot
     Share

    Recommended Posts

    I don't remember if I wrote this or not, enjoy.

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;
    
    public class PriceFetcher {
    
    	/**
    	 * Fetches average item prices from Zybez.
    	 * 
    	 * @param item name
    	 * @return price
    	 * @throws IOException
    	 */
    	public int getPrice(String name) throws IOException {
    		if (name.contains("arrow"))
    			name = name + "s";
    		if (name.equals("Herb"))
    			name = "Unidentified herb";
    		if (name.length() <= 3)
    			return 0;
    
    		URL url = new URL(
    				"http://forums.zybez.net/runescape-2007-prices/api/item/"
    						+ name.replace("+", "%2B").replace(' ', '+')
    								.replace("'", "%27"));
    		URLConnection con = url.openConnection();
    		con.addRequestProperty("User-Agent", "Mozilla/5.0");
    		BufferedReader in = new BufferedReader(new InputStreamReader(
    				con.getInputStream()));
    		String line = "";
    		String inputLine;
    
    		while ((inputLine = in.readLine()) != null)
    			line += inputLine;
    
    		in.close();
    		if (!line.contains("average\":"))
    			return 0;
    
    		System.out.println(line);
    		line = line.substring(line.indexOf("average\":")
    				+ "average\":".length());
    		line = line.substring(0, line.indexOf(","));
    		return (int) Math.round(Double.parseDouble(line));
    	}
    }
    
    Link to comment
    Share on other sites

    Cory (Novum Scripts) wrote this, I believe

    I wrote my own a while back and there's a few similar ones too, but this may he his, not 100% sure.

    Link to comment
    Share on other sites

    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
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.