Skip to content

Instantly share code, notes, and snippets.

@sweemeng
Created April 20, 2010 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sweemeng/372780 to your computer and use it in GitHub Desktop.
Save sweemeng/372780 to your computer and use it in GitHub Desktop.
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