康爱多大药房的登录接口。
请求方式:post
功能说明:登录
登录成功:{"Code":"1","Result":true,"Message":"登录成功!","Data":null}
登录失败:{Code: "UserName", Result: false, Message: "账户名不存在或密码不匹配,请重新输入!", Data: null}
参数名
说明
参数1
userNam
用户名,必填
参数2
pass
密码,必填
参数3
isRemberName
是否记住密码
参数4
loginPlatform
登录平台
使用requests正常编写代码
import requests
url = 'https://tstuser.360kad.com/Login/AjaxLoginV2'
data1 = {
'userName':'账号',
'pass':'密码',
'isRemberName':'false',
'loginPlatform':'1'
}
# 这2种写法都可以
# request = requests.request('post', url, data=data1)
request = requests.post(url, data1)
print(request.text)
if request.json()["Result"] == True: # 返回结果转成json格式
print("登录成功")
else:
print("登录失败,原因是:"+request.json()['Message'])
# postman导出requests格式的代码
import requests
url = "https://tstuser.360kad.com/Login/AjaxLoginV2"
payload = "userName=1232321&pass=12312312321312&isRemberName=false&loginPlatform=1&undefined="
headers = {
'cache-control': "no-cache",
'Postman-Token': "e828e60f-dab3-4c58-815d-fd8ae5652883"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)