Jump to content

Get zybez price method.


Recommended Posts

Posted (edited)

Have fun.

/**
* @author FearMe
* @param name the exact item name
* @return the price(not 100% accurate)
* @throws IOException
*/
    private int getPrice(String name) throws IOException {
     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;
 
        line = line.substring(line.indexOf("average\":\"")
        + "average\":\"".length());
        line = line.substring(0, line.indexOf("\""));
        return (int) Math.round(Double.parseDouble(line));
    }
Edited by FearMe
Posted

If you can extend it to check for buy/sell, and only if there's recent offers, and alch prices, that'd make it a lot more usable. That's what I do for my Slayer script smile.png

This is more for stuff like calculating money gained per hour, nothing big.

If i recall correctly there's a full-fletched library on like the 2nd or 3rd page of this subforum.

Posted

This is more for stuff like calculating money gained per hour, nothing big.

If i recall correctly there's a full-fletched library on like the 2nd or 3rd page of this subforum.

There is one but I don't believe it checks for actual offers, and therefor if there's an item with a price of 1,000,000 but that's only people selling, no one buying, it will still return that (incorrect) result.

Posted (edited)

Totally forgot that some items have a " ' " in the name, plus sign works fine though.

I can't imagine that plus signs would work fine, since they are interpreted as spaces

a Dragon dagger(p+) for example, would be translated to Dragon+dagger(p+) = 3 words: "Dragon", "dagger(p" and ")"

Edited by FrostBug
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...