-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbn-checker.py
46 lines (37 loc) · 1.46 KB
/
nbn-checker.py
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
46
import json
import datetime
import sqlite3 as sl
import os
import sys
from enum import IntEnum
try:
from urllib.request import Request, urlopen # Python 3
except ImportError:
from urllib2 import Request, urlopen # Python 2
nbn_url = 'https://places.nbnco.net.au/places/v2/details/'
location_id = 'LOC000000000000'
#NBN connection / read JSON data
req = Request(nbn_url + location_id)
req.add_header('Referer', 'https://www.nbnco.com.au/')
content = urlopen(req).read()
#JSON file
jsondata = json.loads(content)
reasonCode = jsondata.get('addressDetail').get('reasonCode')
altReasonCode = jsondata.get('addressDetail').get('altReasonCode')
techChangeStatus = jsondata.get('addressDetail').get('techChangeStatus')
programType = jsondata.get('addressDetail').get('programType')
targetEligibilityQuarter = jsondata.get('addressDetail').get('targetEligibilityQuarter')
techType = jsondata.get('addressDetail').get('techType')
formattedAddress = jsondata.get('addressDetail').get('formattedAddress')
print("")
print("---------------------- SUMMARY -----------------")
print("Address: " + formattedAddress)
print("Current Technology: " + techType)
print("reasonCode: " + reasonCode)
print("altReasonCode: " + altReasonCode)
print("techChangeStatus: " + techChangeStatus)
print("programType: " + programType)
print("targetEligibilityQuarter: " + targetEligibilityQuarter)
print("")
print("---------------------- FULL DATA DUMP -----------------")
print(json.dumps(jsondata, indent=4))