-->
当前位置:首页 > DayDayUp > 正文内容

[python]海康威视IVMS 8200平台批量导入卡口

Luz4周前 (11-08)DayDayUp362

背景

8200平台上需要添加一批卡口,但是批量导入无法使用,海康工程师也无法解决


脚本

import requests
import base64
headers={
    'Accept': 'text/html, */*; q=0.01',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Content-Length': '33',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Cookie': '_i18n_locale=zh_CN; home_page=https://xx.xx.xx.xx:443/cas/eportal/home.action; JSESSIONID=64DA1A3AA0054D3FB6C7A3BCBAECE402; alarmDialog_admin=ON; alarmVoice_admin=ON; BMS_LOGIN_COOKIE_ID=7b368d33-b021-44c7-8bad-7cc325d214f6; _i18n_locale=zh_CN; JSESSIONIDNCG=97197FDD347E15CFAC1BAF0C525FE411; /-HIK-CAS=HIK-CAS_TGT-3-QEYQhNmNfsibujynbejZWs4PJlsGFjraFGltHcJfsywdRymVhcF-cas; /-HIK_COOKIE=HIK-SESSION_TGT-3-QEYQ6NmNfsibujynbejZWs4PJlsGFjraFGltHcJfsywdRymVhcF-cas',
    'DNT': '1',
    'Host': 'xx.xx.xx.xx',
    'Origin': 'https://xx.xx.xx.xx',
    'Referer': 'https://xx.xx.xx.xx/bms/web/config/index.do?home_page=https://xx.xx.xx.xx:443/cas/eportal/home.action&_random=9120487361250',
    'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.115 Safari/537.36',
    'X-Requested-With': 'XMLHttpRequest'
    }
def get_code():#获取国标编码
    data={
    'id':'', 
    'controlUnitIndexCode': 'xxxxxx'
    }
    body=requests.post(url='https://xx.xx.xx.1xx/bms/web/config/crossingInfo/init.do',headers=headers,data=data,verify=False).text
    code=body.find('xxxx',0)
    resu=body[code:code+20]
    print(resu)
    return(resu)
def submit(guobiaocode,channelcode,name,jingdu,weidu,ip,password):
    data={
    'crossingInfo.indexCode':channelcode,
    'crossingInfo.gatCode': guobiaocode,
    'crossingInfo.name': name,
    'crossingInfo.laneNum': '1',
    'crossingInfo.frontType': '3',
    'crossingInfo.longitude': jingdu,
    'crossingInfo.latitude': weidu,
    'crossingInfo.crossingServerId': '122', #卡口接入服务器id
    'crossingInfo.crossingMode': '1',
    'crossingInfo.intercity': '1',
    'crossingInfo.usageType': '80',
    'crossingInfo.cloudAnalysis': '0',
    'crossingInfo.onePicMultiVehicle': '1',
    'crossingInfo.relatedCameraCode': '',
    'crossingInfo.internalCode': '',
    'crossingInfo.jccrossingIndexCode': '',
    'crossingInfo.controlUnitIndexCode': 'xxxxxx',#区域编码
    'crossingCameras[0].ip':ip,
    'crossingCameras[0].port': '37777',
    'crossingCameras[0].username': 'admin',
    'crossingCameras[0].password':base64.b64encode(password.encode()).decode(),
    'crossingCameras[0].captureDirection': '1',
    'crossingCameras[0].chanNum': '-1'
    }
    body=requests.post(url='https://xx.xx.xx/bms/web/config/crossingInfo/saveOrUpdate.do',headers=headers,data=data,verify=False).text
    print('1111',body)

kakou="""设备名	设备ip	经度	纬度	密码"""
cameras=kakou.split('\n')
for i in cameras:
    camera=i.split('\t')
    print(camera)
    code=get_code()
    submit(code,code,camera[0],camera[2],camera[3],camera[1],camera[4])


效果

image.png

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。