nzpostaddy
yay maps, something I haven't really used before. Good to try something new.
Using some demo examples from nz post. Examples are printed below.
script to search for addresses.
Gets address from nzpost then displays static map from mapquestapi
In [1]:
    
import json
import shutil
import requests
    
In [2]:
    
opjsres = open('/home/wcmckee/github/nzpostad.json', 'r')
    
In [3]:
    
opjrd = opjsres.read()
    
In [4]:
    
nzpod = json.loads(opjrd)
    
In [5]:
    
nzpod
    
    Out[5]:
In [6]:
    
nzpaddy = nzpod['addresses']
    
In [7]:
    
nzplen = len(nzpod['addresses'])
    
In [8]:
    
nzplen
    
    Out[8]:
In [9]:
    
for nzp in range(0, nzplen):
    nzitm = (nzpaddy[nzp])
    print(nzitm['full_address'])
    
    
In [10]:
    
opsuccessad = open('/home/wcmckee/github/nzpostsuccess.json', 'r')
    
In [11]:
    
opsucrd = opsuccessad.read()
    
In [12]:
    
opjslo = json.loads(opsucrd)
    
In [13]:
    
opjslo
    
    Out[13]:
In [14]:
    
opja = opjslo['address']
    
In [15]:
    
opja
    
    Out[15]:
In [16]:
    
latad = opja['latitude']
    
In [17]:
    
longad = opja['longitude']
    
In [18]:
    
latad
    
    Out[18]:
In [19]:
    
longad
    
    Out[19]:
In [ ]:
    
mapk = open('/home/wcmckee/github/mapkey.txt', 'r')
    
In [ ]:
    
mapkrd = mapk.read()
    
In [ ]:
    
reqimg = 'http://www.mapquestapi.com/staticmap/v4/getmap?key=' + mapkrd + '&size=400,200&zoom=10¢er=' + str(latad) + ',' + str(longad)
    
In [ ]:
    
rmnz = reqimg.replace('\n', '')
    
In [ ]:
    
response = requests.get(rmnz, stream=True)
with open('img.png', 'wb') as out_file:
    shutil.copyfileobj(response.raw, out_file)
del response