How to capture the data from yahoo finance streaming?
Yahoo finance streaming uses a method of a file c开发者_开发技巧onstantly increasing in size to update their data:
http://uk.finance.yahoo.com/q?s=^FTSE
Is there anyway I could collect this data (i'm not going to sell it- wanted to make my own amateur trade screen)?
If you want to parse HTML, I would recommend Apache Jericho. But you better find a RSS/JSON/XML stream.
Regards, Stéphane
You could get the HTML and parse out what you want. Here is some basic code using the Apache client:
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
public class YahooFinanceScraper {
// HTTP GET the given URL
private static String HttpGET(String url) {
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url);
    int responseCode = 0;
    String responseHTML = null;
    try {
        responseCode = client.executeMethod(method);
        responseHTML = method.getResponseBodyAsString();
    } catch (Exception e) {
        // log me!
    } finally {
        method.releaseConnection();
    }
    return response;
}
String quote(String symbol) {
    String data = "";
    String HTML = HttpGET(YAHOO_FINANCE_QUOTE_URL + symbol);
    // BIG TODO: parse the HTML for whatever data you find interesting
    return data;
}
public static void main(String[] args) {
    YahooFinanceScraper y = new YahooFinanceScraper();
    String data = y.quote("FTSE");
}
static final String YAHOO_FINANCE_QUOTE_URL = "http://finance.yahoo.com/q?s=^";
}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论