Skip to content

Instantly share code, notes, and snippets.

@phl0w
Created June 21, 2012 21:11
Show Gist options
  • Select an option

  • Save phl0w/2968560 to your computer and use it in GitHub Desktop.

Select an option

Save phl0w/2968560 to your computer and use it in GitHub Desktop.
/**
* @author Cakemix
* @author Coma
* @param id
* the item id
* @return the price
* @throws IOException
*/
private int getPrice(int id) throws IOException {
URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + id);
URLConnection con = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
con.getInputStream()));
String line = "";
String inputLine;
while ((inputLine = in.readLine()) != null) {
line += inputLine;
}
in.close();
if (!line.contains("mark_price"))
return -1;
line = line.substring(line.indexOf("mark_price\":\"")
+ "mark_price\":\"".length());
line = line.substring(0, line.indexOf("\""));
return Integer.parseInt(line.replaceAll(",", ""));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment