-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddressgeocoder.py
More file actions
45 lines (37 loc) · 1.77 KB
/
addressgeocoder.py
File metadata and controls
45 lines (37 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#########################################################################################################
# Program Name : addressgeocoder.py #
# Program Description: #
# This program geocodes an address using Harmony Suite #
# #
# Comment Date Author #
# ================================ ========== ================ #
# Initial Version 20/07/2017 Engramar Bollas #
#########################################################################################################
import httplib2 as http
import json
import sys
import pprint
try:
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8'
}
uri = 'http://localhost:8080/HarmonyWS/rest/parseCustomerData'
target = urlparse(uri)
method = 'POST'
address = ("\""+"Suite 202 Level 2 220 George St, Sydney NSW 2190"+"\"")
body = '{"harmonyServiceConfig":{"role":"DEMO","includeChanges":false,"failOnError": false,"offset":""},"parserInput":{"rawDataInput":{"address":{"value":%s}}}}' % address
h = http.Http()
response, content = h.request(
target.geturl(),
method,
body,
headers)
json_string = str(content, 'utf8')
jdata = json.loads(json_string)
payld = jdata['ciqPartyDocument']
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(payld)