forked from ABN-SFLookupTechnicalSupport/ABNLookupSampleCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy3sample.py
More file actions
40 lines (36 loc) · 1.46 KB
/
py3sample.py
File metadata and controls
40 lines (36 loc) · 1.46 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
import urllib.request as req
#Search parameters for ABRSearchByNameSimpleProtocol service
#Note, this service requires all parameters to be specified, even if you specify no query parameter
#The parameters specified below will search for an entity with the name 'coles' with postcode '2250'
#In this case, unspecified search parameters all default to 'Y'
#(i.e. will search for the legal & trading name 'coles' in all States and Territories
name = 'coles'
postcode = '2250'
legalName = ''
tradingName = ''
NSW = ''
SA = ''
ACT = ''
VIC = ''
WA = ''
NT = ''
QLD = ''
TAS = ''
authenticationGuid = '' #Your GUID should go here
#Constructs the URL by inserting the search parameters specified above
#GETs the url (using urllib.request.urlopen)
conn = req.urlopen('https://abr.business.gov.au/abrxmlsearchRPC/AbrXmlSearch.asmx/' +
'ABRSearchByNameSimpleProtocol?name=' + name +
'&postcode=' + postcode + '&legalName=' + legalName +
'&tradingName=' + tradingName + '&NSW=' + NSW +
'&SA=' + SA + '&ACT=' + ACT + '&VIC=' + VIC +
'&WA=' + WA + '&NT=' + NT + '&QLD=' + QLD +
'&TAS=' + TAS + '&authenticationGuid=' + authenticationGuid)
#XML is returned by the webservice
#Put returned xml into variable 'returnedXML'
#Output xml string to file 'output.xml' and print to console
returnedXML = conn.read()
f = open('output.xml', 'wb')
f.write(returnedXML)
f.close
print(returnedXML)