| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #!/usr/bin/python3
- # --*-- coding:utf-8 --*--
- import requests, json, os, time
- import pymysql
- import sys
- import time, datetime
- import logging
- Ids = []
- logging.basicConfig(filename='./app_time.log', level=logging.INFO)
- def auth_post():
- url_auth = "http://localhost:8000/auth"
- auth_body = {"username": "123", "password": "123"}
- auth_headers = {
- "Content-Type": "application/json, charset=UTF-8"
- }
- auth_original = requests.request('post', url_auth, json=auth_body, headers=auth_headers)
- access_token_original = auth_original.json()
- access_token = access_token_original['access_token']
- return access_token
- def post_x-www-form():
- init_headers = {'content-type': 'application/x-www-form-urlencoded'}
- init_url = "http://192.1.1.1:8080/init"
- params = {"account_ids":Ids[0]}
- resp = requests.post(init_url, data=params, headers=init_headers)
- print(resp.text)
- def clear_post():
- url_clear = "http://localhost:8000/api/range"
- data_headers = {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer ' + auth_post()}
- json_id = {'ID': Ids}
- data_original = requests.post(url_clear, json=json_id, headers=data_headers)
- # 发送GET请求,参数为10000,带上验证信息(Auth)。
- def get_resource():
- url_clear = "http://localhost:8000/api/source/10000?region=cn-northwest-1"
- data_headers = {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer ' + auth_post()}
- json_id = {'ID': Ids}
- data_original = requests.get(url_clear, headers=data_headers)
|