Python Matplotlib Finance:获取一只股票的季度每股收益

Python Matplotlib Finance: Get the quarterly EPS of a stock

我正在使用 Matplotlib Finance 和 Python 从 Yahoo! 获取股票报价金融。

我想知道是否有办法使用 Matplotlib Finance 获取当前季度以及过去 5 年的季度(即过去 20 个季度)的 EPS(每股收益)。

如果没有,谁能告诉我 python 有这些数据的图书馆?

这对我有用。

from urllib import urlopen
from bs4 import BeautifulSoup

url = 'http://www.marketwatch.com/investing/stock/goog/financials'
text_soup = BeautifulSoup(urlopen(url).read()) #read in

titles = text_soup.findAll('td', {'class': 'rowTitle'})
for title in titles:
    if 'EPS (Basic)' in title.text:
        print [td.text for td in title.findNextSiblings(attrs={'class': 'valueCell'}) if td.text]

结果: [u'15.10', u'16.42', u'18.29', u'20.27', u'23.88'] [u'-',u'8.75%',u'11.38%',u'10.85%',u'17.78%']