I am trying to make a program to go on a stock website find the value a particular stock is at and display it to the user. Then repeat at your selected timeframe.
I can get my code to read the entire source of the page or open a page but I cannot seem to get it to find something within the source.
To give you a better idea of what I would it to do when completed.
Get input from the user on what stock and sight to search and how often to check it. Once the run button is clicked I would like it to take the input from the user and run in the back ground going on the website searching the stock and display the numbers back to the user. I have only been able to have it display the entire source code though, not just the stock numbers.
If anyone has some suggestions I would appreciate it.
Thanks.
import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; public class StockTracker { public static void main(String[] args) { try { URL url = new URL("http://www.goptions.com/trading/"); InputStream stream = url.openStream(); BufferedInputStream buf = new BufferedInputStream(stream); StringBuilder sb = new StringBuilder(); while (true) { int data = buf.read(); if (data == -1) { break; } else { sb.append((char)data); } } System.out.println(sb); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }