Basically, how does a site like bitcoincharts.com gather its statistics? I like coding in python if you want to offer code examples.
BitcoinCharts doesn't show much from the bitcoin network. The market data comes from the exchanges.
Bitcoin Charts shares freely their markets and trade history data:
The original source for the data is accessed from the exchanges themselves. Most exchanges do share their data but the API methods are not standard nor consistent between exchanges.
As far as statistics on the blockchain data, the method will vary on which statistic you are trying to get at as some are stored (confirmed transactions), and others are not (e.g., memory pool contents, double spend transaction attempts, etc.)
If you like python, then Armory provides access to the blockchain. See the Sample Armory code in the extras::