http(python)
2024-10-07 16:19:00
1、client
1) httpie
http -f POST example.org hello=World
http POST
http://192.168.200.251:55101/Api/Client/Login? Account=zdd_1
Password=0192023a7bbd73250516f069df18b500 DeviceCode=20190806 > file
login.json
{
"Account": "zdd_1",
"Password": "0192023a7bbd73250516f069df18b500",
"DeviceCode": "20190806"
}
http POST http://192.168.200.251:55101/Api/Client/Login?/login.json @$(pwd)/login.json
2) python requests
import requests
import json
import datetime
import time
from hashlib import md5 #global var
url_base = 'http://192.168.200.251:55101'
account = "zdd_1"
passwd = "admin123"
device_code = "20190806" #timeStamp
get_now_milli_time = lambda: int(time.time() * 1000) #md5
def encrypt_md5(s):
new_md5=md5()
new_md5.update(s.encode(encoding='utf-8'))
return new_md5.hexdigest() ######################################################## # login
url = url_base + '/Api/Client/Login?'
login = {
"Account": "",
"Password": "",
"DeviceCode": ""
} login['Account'] = account
login['Password'] = encrypt_md5(passwd)
login['DeviceCode'] = device_code r = requests.post(url, data = login)
print(r.status_code)
print(r.text)
d = json.loads(r.text)
print(d['Code'])
token = d['Result']['Token']
ID = d['Result']['Id']
print(token)
print(ID) ######################################################## # get reg info
url = url_base + '/Api/Client/GetDeviceRegister?'
get_reg_info = {
"code": "20190806",
"ssoToken": "",
"stationId": "",
"timeStamp": "",
"accessSignature": ""
} get_reg_info['ssoToken'] = token
get_reg_info['timeStamp'] = str(get_now_milli_time())
get_reg_info['stationId'] = ""
get_reg_info['code'] = device_code
s1 = encrypt_md5(get_reg_info['timeStamp']).upper()
print(s1)
s2 = encrypt_md5(ID + s1).upper()
print(s2)
get_reg_info['accessSignature'] = s2
r = requests.get(url,params=get_reg_info)
print(r.status_code)
print(r.text)
d = json.loads(r.text)
print(d)
最新文章
- Sqlserver查询结果,让某列结果合并一列并且逗号分隔。
- Collection与Map
- Laravel Container分析
- 最后关于Pipeline完整的图如下:
- opencv hog+svm行人检测
- ios开发中的toll-free bridged
- ASP.NET是如何在IIS下工作的[转]
- struts2+Hibernate4+spring3+EasyUI环境搭建之五:引入jquery easyui
- libConfuse的使用
- ZOJ1221 &;&; UVA567:Risk(Floyd)
- FileFilter过滤器
- [ZJOI2011]礼物
- 拉普拉斯平滑处理 Laplace Smoothing
- Math对象的常用属性和方法
- c语言的基础知识
- 磁盘 ->; 硬盘 ->; c盘 &;&; 内存
- python判断变量是否为int、字符串、列表、元组、字典等方法
- 【拓扑排序或差分约束】Guess UVALive - 4255
- Redmine 邮件配置
- ListBox和ComboBox绑定数据简单例子