import urllib2, sys, os
try:
	import bingMapsKey
except:
	print "Failed to find bingMapsKey module. You must have a bingMapsKey.py in the same directory with the text \"key = <your Bing maps key>\""
	sys.exit(1)


def main():
	url = 'http://spatial.virtualearth.net/REST/v1/Dataflows/Geocode?input=pipe&key=%s' % (bingMapsKey.key)
	print url
	filename = 'geocode_input.txt'
	with open(filename, 'r') as f:
		data = f.read()
	print len(data)
	req = urllib2.Request(url, data)
	response = urllib2.urlopen(req)
	responseData = response.read()
	print responseData

if (__name__ == '__main__'):
	main()
