Created
April 20, 2010 17:25
-
-
Save sweemeng/372780 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
# here i use json, but the api also support xml | |
import json | |
# for url parameter, just to make it look nice | |
param = urllib.urlencode({'api':'your api key','format':'json'}) | |
# get population of malaysia | |
url = 'http://open.worldbank.org/countries/my/indicators/SP.POP.TOTL' | |
data = urllib2.urlopen(url+'?'+ param) | |
result = json.load(data) | |
# btw result[0] is the data on the pages etc, data start at index 1 | |
print result[1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment