據我所知,刮標題使用此代碼擦傷的標題是「谷歌公司(GOOG)」 http://finance.yahoo.com/q?s=goog:Jsoup的Java刮tickersymbol
String name = doc.select(".title h2").first().text();
我不知道如何刮稱號,並分別tickersymbol「谷歌公司 「和 」GOOG「:
據我所知,刮標題使用此代碼擦傷的標題是「谷歌公司(GOOG)」 http://finance.yahoo.com/q?s=goog:Jsoup的Java刮tickersymbol
String name = doc.select(".title h2").first().text();
我不知道如何刮稱號,並分別tickersymbol「谷歌公司 「和 」GOOG「:
(1)我湊解決方案:
這是一個簡單的答案不包括異常處理線,但是,它是短,制定出框。
public static void main(String[] args) throws IOException {
// collect the html and create the doc
String url = "http://finance.yahoo.com/q?s=goog";
Document doc = Jsoup.connect(url).get();
// locate the header, title and then found the h2 tag
Element header = doc.select("div[id=yfi_rt_quote_summary]").get(0);
Element title = header.select("div[class=title]").get(0);
String h2 = title.select("h2").get(0).text();
// split by open parenthesis (double escape) and strip off the close parenthesis
// TODO - regular expression help handle situation where exist multiple "()"s
String[] parts = h2.split("\\(");
String name = parts[0];
String shortname = parts[1].replace(")", "");
System.out.println(name);
System.out.println(shortname);
}
輸出看起來是這樣的:
Google Inc.
GOOG
(2)我沒有湊解決方案:
這是真的a nice post您展示如何下載雅虎數據編程。
我也是一個R用戶,它對R內的get Yahoo finance數據非常容易。您可以在那裏進行分析並將其保存到文件或數據庫中(如果需要)。 :)
你想刮ID的: 」yfs_184_goog「,yfs_c63_goog」 和 「yfs_p43_goog」
這些是大黑數字,它旁邊的小紅/綠數字和百分比。
雅虎財務是否爲此提供API? – halfer