找了一个不需要验证码登录的网站,康爱多网上药店,使用Python+requests框架实现接口自动化,选择登录-加购-下单-取消订单-删除订单一条业务链五个接口测试,代码如下:
import requests
import time
# 登录
session = requests.session()
body = {
'userName': 'xxxxxxxxxxx',
'pass': 'xxxxxxxxx'
}
login = session.post('https://user.360kad.com/Login/AjaxLoginV2', data=body)
print(login.text)
# 加入购物车
cartparam = {
'id': 1406,
'quantity': 1,
'buyType': 0,
'sellerCode': '',
'rd': 0.7634724674063651
}
cart = session.get('https://www.360kad.com/cart/AddCart', params=cartparam)
print(cart.text)
# 提交订单
orderdata = {
'AddressId': 11710216491,
'PayType': 1,
'InvoiceType': 0,
'InvoiceTitle': '',
'InvoiceCustomerType': 1,
'InvoiceDutyParagraph': '',
'IsInvoice': 0,
'CartType': 0,
'SendTimeType': 0,
'Remark':