I have this code:
import urllib, urllib2, re import xml.etree.ElementTree as ET from bs4 import BeautifulSoup # The get_zipcode(address) function will be called with an address string with # no zip code, such as 'Lowell Observatory, Flagstaff, AZ', and it should return the # ZIP code of the address as a string # For example, get_zipcode('Lowell Observatory, Flagstaff, AZ') should return '86001' # Use the Google Geocoding API to obtain the ZIP code. Documentation: # https://developers.google.com/maps/documentation/geocoding/ # Can use either json or xml output format. def get_zipcode(address): zipcode = '' # +++your code here+++ url_values = urllib.urlencode(address) url="http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false" % address #return zipcode response = urllib2.urlopen(url) return response
I'm getting an error when I return response and I don't know why. Also, I'm not exactly if I am going about this the right way at all.