Beginner learning python When using scrapy to collect web page images, the other party will prohibit cross-domain display, so I came up with the idea of ??saving the images on Qiniu Cloud, but the python API of Qiniu Cloud is a bit confusing, so I came here I would like to ask if there is a demo for saving remote pictures to Qiniu Cloud. If so, can you post it for reference and study? Thank you very much!
from qiniu import Auth, BucketManager
# 抓取文件到七牛
def fetch(url):
filename = str(time.time()).replace('.', '')
# 獲取鑒權(quán)對(duì)象
auth = Auth(access_key, secret_key)
# 初始化BucketManager
bucket_manager = BucketManager(auth)
ret, info = bucket_manager.fetch(url, bucket_name, filename)
if info.status_code == 200:
file_url = bucket_domain + filename
return file_url
else:
return False