import json
import urllib2


username = 'DEVELOPX'
password = 'TEST1234'
url1 = 'https://legallandconverter.com/'
url2 = 'https://legallandconverter.com/cgi/shopats201703.cgi?quarter=&section=2&township=2&range=2&meridian=W4&cmd=forward&output=geojson'

# INSTALL PASSWORD AUTHENTICATION

auth = urllib2.HTTPBasicAuthHandler()
auth.add_password("Administrator",url1,username,password)
opener = urllib2.build_opener(auth)
urllib2.install_opener(opener)

# GET DATA FROM MOTHERSHIP

feed = urllib2.urlopen(url2)

data = json.load(feed)


# RETRIEVE AND PRINT DATA OUT OF THE JSON BLOB

# Conversion Status

print data['success']
print

# Text Data

print data['features'][0]['properties']['DLSSHORT']
print data['features'][0]['properties']['QUARTER']
print data['features'][0]['properties']['SECTION']
print data['features'][0]['properties']['TOWNSHIP']
print data['features'][0]['properties']['RANGE']
print data['features'][0]['properties']['MERIDIAN']
print data['features'][0]['properties']['PROVINCE']
print data['features'][0]['properties']['COUNTY']
print data['features'][0]['properties']['LATITUDE']
print data['features'][0]['properties']['LONGITUDE']
print data['features'][0]['properties']['ZOOM']
print data['features'][0]['properties']['MGRS']
print data['features'][0]['properties']['UTM']
print data['features'][0]['properties']['NTS']
print data['features'][0]['properties']['PID']
print

# Polygon Coordinate Pairs

print data['features'][0]['geometry']['coordinates'][0][0]
print data['features'][0]['geometry']['coordinates'][0][1]
print data['features'][0]['geometry']['coordinates'][0][2]
print data['features'][0]['geometry']['coordinates'][0][3]
print data['features'][0]['geometry']['coordinates'][0][4]
print

# Print Longitude and Latitude Seperately

print data['features'][0]['geometry']['coordinates'][0][0][0]
print data['features'][0]['geometry']['coordinates'][0][0][1]

print

