Eliot 193 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)); } }
GoldenGates 72 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.
Eliot 193 Author Posted December 24, 2014 Cory (Novum Scripts) wrote this, I believe No, I don't think he did.
Anaesthetic 24 Posted December 27, 2014 No, I don't think he did. Nvm I talked to him and he said he didn't write this
Recommended Posts
Archived
This topic is now archived and is closed to further replies.