python-requests请求

#! /usr/bin/env python
# -*- coding:utf-8 –*-

import json
import time
import hashlib
import requests

rid = 'zhoujt_test'
user = 'zhoujiangtao'
token = 'xxxxxxxxxxxxx'
nowtime = int(time.time())
signstr = user + str(nowtime) + rid + token
signature = md5hash.hexdigest()

headers = {
    'User': user,
    'Timestamp': str(nowtime),
    'cc_request_id': rid,
    'Authorization': signature,
    'Content-Type': 'application/json'
}
# 查询
list_url = "xxxxxxxxxxxxx/list/"

# 查看data
data = {"Job": "linux", "Token": "xxxxxxxxxxxxx"}

res = requests.request("POST", url=list_url, data=json.dumps(data), headers=headers)
print(res.json())

 

posted @ 2021-12-20 16:31  Security  阅读(122)  评论(0编辑  收藏  举报