#!/usr/bin/env python -- coding: utf-8 --
import json
import requests
from email.utils import formatdate
from datetime import datetime
from time import mktime
from hashlib import sha1
import hashlib
tasks_id = "open:qpuovvjukmijeyssuyaxvconxuxtpbi"
now = datetime.now()
stamp = mktime(now.timetuple())
d = formatdate(timeval=stamp, localtime=False, usegmt=True)
print(d)
url = r"https://solution.wps.cn/api/developer/v1/tasks/%s" % tasks_id
print(url)
body = r"/api/developer/v1/tasks/%s" % tasks_id
APPID = "SX20241114PDAAVN"
APPKEY = b"MYyysVsbsWOQoLBeiXdXJPRMFtNNngYw"
Content_Type = b"application/json"
Date = d.encode("utf-8")
print(Date)
Content_Md5 = hashlib.md5(body.encode('utf-8')).hexdigest().encode('utf-8')
print(Content_Md5)
signature = sha1(APPKEY+Content_Md5+Content_Type+Date).hexdigest()
print(signature)
Authorization = 'WPS-2:%s:%s' % (APPID, signature)
print(Authorization)
headers = {
'Date': "%s" % d,
'Content-Md5': "%s" % Content_Md5,
'Content-Type': Content_Type,
'Authorization': "%s" % Authorization
}
re = requests.get(url=url, headers=headers) data = re.content
print(data) if re.status_code == 200: d = json.loads(data) print(d)