建模程序 多个定时程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
1.2 KiB

import requests
#url
#循环100次
for i in range(100):
url = "https://mp.api.suwa3d.com/api/oss/putSignURL?key_name=photos/233522/photo2/"+str(i)+".jpg"
#请求url
res = requests.get(url)
#打印结果
print(res.text)
#转json
res_json = res.json()
ossUrl = res_json['data']
print(f"当前是第几个:{i}, ossUrl: {ossUrl}")
# data 是一个 oss 的上传连接, 向这个上传连接发送一个文件
# 上传文件
try:
#with open("E:/microservice/make2/data/0.jpg", 'rb') as f:
file = open('E:/microservice/make2/data/0.jpg', 'rb')
response = requests.put(ossUrl, data=file, headers={"Content-Type": "application/octet-stream"})
print(response.status_code)
if response.status_code == 200:
upload_is_ok = True
else:
print(f"上传图片异常,状态码: {response.status_code}")
except RequestException as e:
print(f"上传异常: {str(e)}")
# file = open('E:/microservice/make2/data/0.jpg', 'rb')
# res = requests.put(ossUrl, data=file)
# print(res.text)
# url = "https://mp.api.suwa3d.com/api/oss/putSignURL?key_name=objs/photos/233522/a.jpg"