处理图片下载流程

This commit is contained in:
liuwei
2025-04-28 13:23:33 +08:00
parent 54f056046d
commit 3af19fe253
2 changed files with 43 additions and 5 deletions

View File

@@ -75,5 +75,46 @@ def send_file():
print(response.text)
def download_file():
url = "/message/downloadImage"
xml ="""<?xml version="1.0"?>
<msg>
<img aeskey="d57b3b0f339a09014a615d2b20e2cb67" encryver="1" cdnthumbaeskey="d57b3b0f339a09014a615d2b20e2cb67" cdnthumburl="3057020100044b304902010002042d0c366c02032dd08502046e5c0caf0204680f0e52042435323638326132302d646232652d343361632d616638332d6632373561343166353039360204052418020201000405004c537500" cdnthumblength="8976" cdnthumbheight="69" cdnthumbwidth="150" cdnmidheight="0" cdnmidwidth="0" cdnhdheight="0" cdnhdwidth="0" cdnmidimgurl="3057020100044b304902010002042d0c366c02032dd08502046e5c0caf0204680f0e52042435323638326132302d646232652d343361632d616638332d6632373561343166353039360204052418020201000405004c537500" length="72485" md5="9a2b154bc39c3148e624693ad1b90d7e" originsourcemd5="9a2b154bc39c3148e624693ad1b90d7e">
<secHashInfoBase64 />
<live>
<duration>0</duration>
<size>0</size>
<md5 />
<fileid />
<hdsize>0</hdsize>
<hdmd5 />
<hdfileid />
<stillimagetimems>0</stillimagetimems>
</live>
</img>
<platform_signature />
<imgdatahash />
<ImgSourceInfo>
<ImgSourceUrl />
<BizType>0</BizType>
</ImgSourceInfo>
</msg>
"""
payload = json.dumps({
"appId": app_id,
"type": 2,
"xml": xml
})
headers = {
'X-GEWE-TOKEN': 'cb43f52db27e4a56bb6ec7da54373582',
'Content-Type': 'application/json'
}
response = requests.request("POST", base_url+url, headers=headers, data=payload)
print(response.text)
if __name__ == '__main__':
set_call_back()
download_file()

View File

@@ -122,11 +122,8 @@ class MessageStorage:
# 确保目标目录存在
if not os.path.exists(target_dir):
os.makedirs(target_dir, exist_ok=True)
# 延时10秒下载试试
logger.info(f"延时10秒下载图片{msg.content.xml_content}")
time.sleep(10)
# 尝试使用wcf下载图片到分组后的目录
json = self.client.download_image(msg.appid, msg.content.xml_content, 1)
json = self.client.download_image(msg.appid, msg.content.xml_content, 2)
# {
# "ret": 200,
# "msg": "操作成功",