Jsoup Java刮取tickersymbol

Jsoup Java刮取tickersymbol,java,web-scraping,jsoup,yahoo-finance,Java,Web Scraping,Jsoup,Yahoo Finance,我理解,删除标题使用此代码删除标题“Google Inc(GOOG)”: 我想知道如何分别刮去标题和股票代码“谷歌公司”和“谷歌”: 您想刮取id:“yfs_184_-goog”、“yfs_c63_-goog”和“yfs_p43_-goog” 这些是黑色大数字,旁边的红色/绿色小数字和百分比 您想刮取id:“yfs_184_-goog”、“yfs_c63_-goog”和“yfs_p43_-goog” 这些是黑色大数字,旁边的红色/绿色小数字和百分比 您想刮取id:“yfs_184_-goog”、

我理解,删除标题使用此代码删除标题“Google Inc(GOOG)”:

我想知道如何分别刮去标题和股票代码“谷歌公司”和“谷歌”:


您想刮取id:“yfs_184_-goog”、“yfs_c63_-goog”和“yfs_p43_-goog”

这些是黑色大数字,旁边的红色/绿色小数字和百分比


您想刮取id:“yfs_184_-goog”、“yfs_c63_-goog”和“yfs_p43_-goog”

这些是黑色大数字,旁边的红色/绿色小数字和百分比


您想刮取id:“yfs_184_-goog”、“yfs_c63_-goog”和“yfs_p43_-goog”

这些是黑色大数字,旁边的红色/绿色小数字和百分比


您想刮取id:“yfs_184_-goog”、“yfs_c63_-goog”和“yfs_p43_-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) 我不必刮取解决方案:

这里向您展示了如何以编程方式下载yahoo数据

我也是R用户,在R中保存数据非常容易。您可以在那里进行分析,并根据需要将其保存到文件或数据库中。:)

(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) 我不必刮取解决方案:

这里向您展示了如何以编程方式下载yahoo数据

我也是R用户,在R中保存数据非常容易。您可以在那里进行分析,并根据需要将其保存到文件或数据库中。:)

(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) 我不必刮取解决方案:

这里向您展示了如何以编程方式下载yahoo数据

我也是R用户,在R中保存数据非常容易。您可以在那里进行分析,并根据需要将其保存到文件或数据库中。:)

(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) 我不必刮取解决方案:

这里向您展示了如何以编程方式下载yahoo数据


我也是R用户,在R中保存数据非常容易。您可以在那里进行分析,并根据需要将其保存到文件或数据库中。:)

Yahoo Finance是否为此提供API?Yahoo Finance是否为此提供API?Yahoo Finance是否为此提供API?Yahoo Finance是否为此提供API?