筛选的接口, 取回包值

from requests import post
from requests import get

# 把网址先设置好
requests_login = post(
url="https://cloud.huaxiaerp.vip/jshERP-boot/user/login",
json={"loginName": "Dmingo", "password": "b678d1268290255da69d7f3ebf68d4cf"}
)

login_result = requests_login.json()
login_token = login_result.get("data").get("token")

print(login_token)

getGoodsList = get(
url="https://cloud.huaxiaerp.vip/jshERP-boot/api/plugin/produce/bom/getGoodsList",
params={
"t": "1637480544",
"search": str({"key": "", "categoryId": ""}),
"column": "createTime",
"order": "desc",
"field": "id,,,mBarCode,name,categoryName,standard,model",
"currentPage": 1,
"pageSize": 10
},
headers={"x-access-token": login_token}
)

getGoodsList_1=getGoodsList.json()
print(getGoodsList_1)
#json串, 没有code? code要在json 里面解析,也不是text 所以不能打印text,所以下面两个打印不可用
#print(getGoodsList_1.text)
#print(getGoodsList_1.status_code)

getGoodsLis_satist = getGoodsList_1
product_code=getGoodsLis_satist.get("code")
product_one_ID = getGoodsLis_satist.get("data").get("total")#[0].get("id")如果是row[里面有值, 就可以用前面的0,get ID]
print(product_code)
print(product_one_ID)
posted @ 2021-11-21 16:35  icy欢仔  阅读(33)  评论(0编辑  收藏  举报