Scraping financial data with R and rvest -


i trying financial data morningstar.com; want i.e. msft yearly revenue data.
they in row <div>of main <div> table.
i followed samples main table:

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() 

but empty list(). html_nodes returns {xml_nodeset (0)} don't know how handle.

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 , development  9043.00  9811.00 10411.00 11381.00 12046.00 11943.00 6                                 sales, general , administrative 18162.00 18426.00 20425.00 20632.00 20324.00 19862.00 7                             restructuring, merger , 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 income taxes  4921.00  5289.00  5189.00  5746.00  6314.00  5851.00 15                            net income 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 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 

it's super-helpful make browser developer tools "network" tab bff.

(that url came inspecting "export" button does).


Comments