Eliot 193 Share Posted December 20, 2014 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)); } } Zhendos 1 Link to comment Share on other sites More sharing options...
Anaesthetic 24 Share Posted December 21, 2014 Cory? Link to comment Share on other sites More sharing options...
Eliot 193 Author Share Posted December 21, 2014 Cory? Who? Link to comment Share on other sites More sharing options...
Anaesthetic 24 Share Posted December 24, 2014 Who? Cory (Novum Scripts) wrote this, I believe Link to comment Share on other sites More sharing options...
GoldenGates 72 Share Posted December 24, 2014 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 More sharing options...
Eliot 193 Author Share Posted December 24, 2014 Cory (Novum Scripts) wrote this, I believe No, I don't think he did. Link to comment Share on other sites More sharing options...
Anaesthetic 24 Share Posted December 27, 2014 No, I don't think he did. Nvm I talked to him and he said he didn't write this Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now