开发者

Stock Symbols using python

I am looking for some stock symbol look-up API. I could able 开发者_如何学JAVAto query yahoo finance with a symbol & could able to retrieve the stock price & other details.

Is there any API for stock symbol searches

Any help would be great ..

Thanks


You could use Python's urllib or the mechanise library to scrape the data from a website which publishes this data. Mechanise would be a better choice if the website requires some interaction before you can get hold of the data (like logging in).

EDIT - for getting stock quote for BT from Yahoo's UK site:

>>> import urllib
>>> import re
>>> data = urllib.urlopen('http://uk.finance.yahoo.com/q?s=BT&m=L&d=').read()
>>> re.search('<span id="yfs_l10_bt-a\.l".*?>([0-9.]+)', data).group(1)
'122.00'

The id in the regular expression was taken by viewing the source of the page and finding the id of the tag that surrounded the data required.


As an alternative to parsing the HTML you could be downloading a clean pre-formatted .csv file. See the tutorial at http://www.gummy-stuff.org/Yahoo-data.htm. Found it in the question awatts linked to.


Take a look at the Company Fundamentals API at http://www.mergent.com/servius

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜