private static String defaultBaseUrl = "http://www.google.com/finance/info?infotype=infoquoteall&q="; private static String defaultSymbolsFile = System.getProperty("user.home") + "/Desktop/NasdaqSymbols.csv"; private static boolean friendlyPrint = true; public static void main(String[] args) throws Exception { ArrayList<String> symbols = FileUtils.getTextListValues(defaultSymbolsFile); StringBuilder syms = new StringBuilder(); //lets do the 1st 100 for (int i = 0; i < 100; i++) { syms.append(symbols.get(i) + ","); } String sb = Util.fetchURL(defaultBaseUrl + syms); JSONArray json = (JSONArray) new JSONParser().parse(sb.substring(3)); console.utils.GoogleFinancePrinter.printJsonArray(json, friendlyPrint); } public static String fetchURL(String url) throws Exception { URL gf = new URL(url); URLConnection yc = gf.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader( yc.getInputStream())); StringBuilder sb = new StringBuilder(); String inputLine; while ((inputLine = in.readLine()) != null) sb.append(inputLine); in.close(); return sb.toString(); } public static void printJsonArray(JSONArray json, boolean friendly) { if (friendly) { for (int i = 0; i < json.size(); i++) { System.out.println("ID: " + ((JSONObject) json.get(i)).get("id")); System.out.println("Symbol: " + ((JSONObject) json.get(i)).get("t")); System.out.println("Name: " + ((JSONObject) json.get(i)).get("name")); System.out.println("Type: " + ((JSONObject) json.get(i)).get("type")); System.out.println("Exchange: " + ((JSONObject) json.get(i)).get("e")); System.out.println("LastTrade: $" + ((JSONObject) json.get(i)).get("l")); System.out.println("Last Trade: " + ((JSONObject) json.get(i)).get("lt")); System.out.println("Change: " + ((JSONObject) json.get(i)).get("c") + "(" + ((JSONObject) json.get(i)).get("cp") + "%)"); System.out.println("------------------------------"); } } else { System.out.print(json.toJSONString()); } }