据我所知,刮标题使用此代码擦伤的标题是“谷歌公司(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