终于调同登录接口了
import requests import json import unittest import HTMLTestRunner ur1='http://118.178.247.67:8081/systLogonUser/adminLogon.do' headers = {'Content-Type':'application/x-www-form-urlencoded','Referer':'118.178.247.67'} data = { 'userName':18200717087 , 'pwd': '123456Aa', 'verifyCode': 121 } r = requests.post(url=ur1,data=data,headers=headers) #r=requests.post(url = ur1,json = data ,headers = headers) #r = requests.post(url = ur1,json = data ,headers = headers) repones = r.text print(r.text) print(r.status_code)
遇到及解决的问题:
1、如果需要打印出测试结果报告是使用这个东西:HTMLTestRunner.文件安装了默认是python2 的经过一系列修改才改成了兼容3
Mac 安装HTMLTestRunner模块
也可以直接下载修改好的 : https://pan.baidu.com/s/1034LdrkP_DYJOVrtwofh9g(2hww)
2、查看数据也没有问题:
开始时遇到的问题:手机号、验证码均加了双引号导致出错
放到这里看看能不能解析 https://www.json.cn/