gpt4 book ai didi

r - 使用 R 和 rvest 抓取财务数据

转载 作者:行者123 更新时间:2023-12-01 11:28:53 25 4
gpt4 key购买 nike

我正在尝试从 morningstar.com 获取财务数据;我想得到 i.e. MSFT yearly revenue data .
他们排成一排<div>一个主要<div>表。
我按照一些样本得到了主表:

url <- "http://financials.morningstar.com/income-statement/is.html?t=MSFT&region=usa&culture=en-US"
table <- url %>%
read_html() %>%
html_nodes(xpath='//*[@id="sfcontent"]/div[3]/div[3]') %>%
html_table()

但我得到一个空的 list() . html_nodes本身返回 {xml_nodeset (0)}我不知道如何处理。

最佳答案

read.csv("http://financials.morningstar.com/ajax/ReportProcess4CSV.html?&t=XNAS:MSFT&region=usa&culture=en-US&cur=&reportType=is&period=12&dataType=A&order=asc&columnYear=5&curYearPart=1st5year&rounding=3&view=raw&r=865827&denominatorView=raw&number=3", skip=1)

Fiscal.year.ends.in.June..USD.in.millions.except.per.share.data. X2011.06 X2012.06 X2013.06 X2014.06 X2015.06 TTM
1 Revenue 69943.00 73723.00 77849.00 86833.00 93580.00 90758.00
2 Cost of revenue 15577.00 17530.00 20249.00 26934.00 33038.00 31972.00
3 Gross profit 54366.00 56193.00 57600.00 59899.00 60542.00 58786.00
4 Operating expenses NA NA NA NA NA NA
5 Research and development 9043.00 9811.00 10411.00 11381.00 12046.00 11943.00
6 Sales, General and administrative 18162.00 18426.00 20425.00 20632.00 20324.00 19862.00
7 Restructuring, merger and acquisition NA NA NA 127.00 NA NA
8 Other operating expenses NA 6193.00 NA NA 10011.00 8871.00
9 Total operating expenses 27205.00 34430.00 30836.00 32140.00 42381.00 40676.00
10 Operating income 27161.00 21763.00 26764.00 27759.00 18161.00 18110.00
11 Interest Expense 295.00 380.00 429.00 597.00 781.00 869.00
12 Other income (expense) 1205.00 884.00 717.00 658.00 1127.00 883.00
13 Income before taxes 28071.00 22267.00 27052.00 27820.00 18507.00 18124.00
14 Provision for income taxes 4921.00 5289.00 5189.00 5746.00 6314.00 5851.00
15 Net income from continuing operations 23150.00 16978.00 21863.00 22074.00 12193.00 12273.00
16 Net income 23150.00 16978.00 21863.00 22074.00 12193.00 12273.00
17 Net income available to common shareholders 23150.00 16978.00 21863.00 22074.00 12193.00 12273.00
18 Earnings per share NA NA NA NA NA NA
19 Basic 2.73 2.02 2.61 2.66 1.49 1.51
20 Diluted 2.69 2.00 2.58 2.63 1.48 1.50
21 Weighted average shares outstanding NA NA NA NA NA NA
22 Basic 8490.00 8396.00 8375.00 8299.00 8177.00 8114.00
23 Diluted 8593.00 8506.00 8470.00 8399.00 8254.00 8183.00
24 EBITDA 31132.00 25614.00 31236.00 33629.00 25245.00 24983.00

让浏览器开发人员工具“网络”选项卡成为您的 BFF 非常有帮助。

(该 URL 来自检查“导出”按钮的作用)。

关于r - 使用 R 和 rvest 抓取财务数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34981137/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com