-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkk5.py
48 lines (37 loc) · 1.58 KB
/
pkk5.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
47
48
# coding=utf-8
import argparse
import requests
def get_args():
parser = argparse.ArgumentParser(description='simple script get some information by cadastral number')
parser.add_argument('-t', '--object_type', action="store", dest="type", type=str, required=True,
help="1 for area, 5 for OKS")
parser.add_argument('-cn', '--cadastral_number', action="store", dest="cn", type=str, required=True,
help="coordinates separated by whitespace")
args = parser.parse_args()
return args
def get_headers():
headers = {
'pragma': 'no-cache',
'referer': 'https://pkk5.rosreestr.ru/',
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36',
'x-requested-with': 'XMLHttpRequest',
}
return headers
def get_data(obj_type, cn):
headers = get_headers()
r = requests.get('http://pkk5.rosreestr.ru/api/features/{0}/{1}'.format(obj_type, cn), headers=headers).json()
return r
def main():
data = get_data(get_args().type, get_args().cn)
print("атрибуты объекта: %s" % get_args().cn)
for attr in data['feature']['attrs']:
print(attr, data['feature']['attrs'][attr])
print("координаты:")
print("\tцентр")
for coord in data['feature']['center']:
print("\t", coord, data['feature']['center'][coord])
print("\textent")
for extent in data['feature']['extent']:
print("\t", extent, data['feature']['extent'][extent])
if __name__ == "__main__":
main()