使用python通过任务id获取转换后的文件链接信息时提示md5问题,我对文件的路径进行加密也对rul进行字符不转译操作但是还是不行

Viewed 3

#!/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)

1 Answers

急!急!急!试了各种转换办法还是不行,一直提示md5,有没有技术人员看下啥原因那,请求过去的是什么

你好,类似的问题在社区很多,可以参考 https://solution-community.wps.cn/questions/10010000000006576/10020000000006578