Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.URL;
- public class ShowData {
- public void fetch(String stockNo) throws IOException {
- URL httpurl = new URL("http://tw.stock.yahoo.com/q/q?s=" + stockNo);
- BufferedReader br = new BufferedReader(new InputStreamReader(httpurl.openStream(), "Big5"));
- String result = "";
- String tmp;
- while ((tmp = br.readLine()) != null) {
- if (tmp.contains("href=\"/q/bc?s=" + stockNo + "\">")) {
- System.out.println(tmp.substring(tmp.indexOf(">") + 1, tmp.indexOf("<")));
- result = result + tmp.substring(tmp.indexOf(">") + 1, tmp.indexOf("<"));
- }
- if (tmp.contains("<td align=\"center\" bgcolor=\"#FFFfff\" nowrap><b>")) {
- System.out.println(tmp.substring(tmp.indexOf("b>") + 2, tmp.indexOf("</")));
- result = result + " " + tmp.substring(tmp.indexOf("b>") + 2, tmp.indexOf("</"));
- }
- }
- br.close();
- System.out.println(result);
- }
- public static void main(String[] args) throws IOException {
- new ShowData().fetch("0050");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment