# 摄像头信息获取

# 海康威视API

import requests,json
requestData={
  "client_id":"12345677",
  "client_secret":"123456546fghfhgh"
}

token = requests.post("https://targetip/artemis/oauth/token",data=requestData,verify=False);
print(token.text)
json1 = eval(token.text)
print(json1["access_token"])

MyHeader={
    "Content-Type":"application/json",
    "access_token":json1["access_token"],
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.81",
    "Accept":"*/*",
    "Host":"targetip",
    "Accept-Encoding":"gzip, deflate, br"
}


requestData1={
    "pageNo":1,
    "pageSize":10
}

data_json = json.dumps(requestData1)

cameraList = requests.post("http://targetip/artemis/api/resource/v1/cameras",data=data_json,headers=MyHeader,verify=False);

print(cameraList.text)

requestData2={
    "cameraIndexCode": "a4e8edbae2b3417682d3ef02c8984334",
    "streamType": 0,
    "protocol": "rtsp",
    "transmode": 1,
    "expand": "streamform=ps"
}

data_json2 = json.dumps(requestData2)

cameraList = requests.post("https://targetip/artemis/api/video/v1/cameras/previewURLs",data=data_json2,headers=MyHeader,verify=False);

print(cameraList.text)
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