aiyehui

导航

 
import asyncio
import aiohttp
import requests
from utils.login import *


#
# async def main():
# data = {
# "password": "123456",
# "username": "admin"
# }
# ret = requests.post(url='http://49.234.14.39:5001/user/login', json=data)
# _token = ret.json()['access_token']
# print('_token', _token)
#
# url3 = 'http://124.220.179.221:8081/cms/manage/loginJump.do'
# data3 = {"userAccount": 'admin', "loginPwd": '123456'}
# res = requests.post(url3, data=data3)
# _cookie = res.cookies
# #
# # # async with aiohttp.ClientSession('http://49.234.14.39:5001') as session:
# # # data2 = {'access_token':_token}
# # #
# # # async with session.post('/user/init', json=data2) as resp:
# # # print(resp.status)
# # # print(await resp.json())
# # #
# # # async with session.post('/user/query', json=data2) as res:
# # # print(res.status)
# # # print(await res.json())
# #
# # async with aiohttp.request(method='post', url='http://49.234.14.39:5001/user/init',
# # json={'access_token': _token}) as res:
# # print(res.status)
# # print(await res.json(), type(res.json()))
# data4 = {
# "id": "",
# "userName": "wind123456789",
# "userSex": 1,
# "userMobile": "18805514688",
# "userEmail": "456@qq.com",
# "userAccount": "wind123456789",
# "loginPwd": "123456",
# "confirmPwd": "123456"
# }
# async with aiohttp.request(method='post', url='http://124.220.179.221:8081/cms/manage/saveSysUser.do',
# data=data4, cookies=_cookie) as res:
# print(res.status)
# print(await res.json(), type(res.json()))


# asyncio.run(main())


class TestAioHttp:

def __init__(self):
self._cookie = get_cookie()
self._token = get_token()

async def cms(self):
data4 = {
"id": "",
"userName": "wind123456789",
"userSex": 1,
"userMobile": "18805514688",
"userEmail": "456@qq.com",
"userAccount": "wind123456789",
"loginPwd": "123456",
"confirmPwd": "123456"
}
for i in range(10):
async with aiohttp.request(method='post', url='http://124.220.179.221:8081/cms/manage/saveSysUser.do',
data=data4, cookies=self._cookie) as res:
print(res.status)
print(await res.json(), type(res.json()))

async def json_token(self):
async with aiohttp.request(method='post', url='http://49.234.14.39:5001/user/init',
json={'access_token': self._token}) as res:
print(res.status)
print(await res.json(), type(res.json()))


if __name__ == '__main__':
t = TestAioHttp()

asyncio.run(t.cms())
asyncio.run(t.json_token())
posted on 2022-06-20 18:09  小灰叶  阅读(43)  评论(0)    收藏  举报