Generally, there are two categories of methods can assist you obtain stock market data. The first one, you can direct access to data by paying money to resellers on web which provide both historical and instant data conveniently and also may allow you custom the data you want, like period and format. The other one category has been more discussed on web, it is to programming codes yourself to get the data for free which my choice here, and this blog is to server as the collection of these methods I have found on web.
(1) some outstanding blogs gives the introduction of this topic, and helps to form basic concepts here,
http://www.cppblog.com/wangjs720/archive/2009/07/14/90061.html
http://blog.sciencenet.cn/blog-461456-455211.html
(2) implementation via various languages. Most of following methods haven't been tested since I only will take C++ as choice and use MATLAB method as back up in case that I failed with C++, and may be R package also a good choice since it indicates that it is a professional finance focused package
C++
Excel VBA
PHP
http://www.phpro.org/classes/Yahoo-Stock-Report.html
Java
http://roruby.iteye.com/blog/169821
http://blog.csdn.net/stanmarsh/article/details/9004583
Matlab
http://blog.sina.com.cn/s/blog_444222ed0101ezz8.html
http://blog.sina.com.cn/s/blog_4cf8aad30102eg78.html
package in R
http://site.douban.com/182577/widget/notes/10568316/note/264808127/
Python
http://smilejay.com/2011/11/python_fetch_stock_info/