Hello.
I am trying to have a program go on one of the stock trading websites and read the number a stock or currency is at and display or save it.
I have it reading and displaying the binary code but I don’t see how to have it find the numbers I would like to get.
On the site you would have to go on the page and click some tabs to trade and maybe the stock you would like, it doesn’t really matter what one it returns as this is more just an idea I thought of that would help me learn more about programming. Although I would like to have it search out a selected stock eventually to take it to the net level. I think my biggest problem is I can’t see how to access the stock numbers in the code. I looked for different click events but don’t see how to have a program do this.
I do not intend to have it display all the code like it is now. I just did it like that to see what I was getting. I will just have a small toolbar with options and a display.
Sorry if this is a bit of a mess, I am new to all this but it interests me I look forward to when I can have an Idea for a app or game and bring it to like.
If anyone can point me in the right direction that would be great.
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(); } } }