search

Home  >  Q&A  >  body text

Python - Looking for a demo of Qiniu Cloud remote image uploading

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!

代言代言2720 days ago888

reply all(1)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-12 09:28:44

    from qiniu import Auth, BucketManager
    # 抓取文件到七牛
    def fetch(url):
        filename = str(time.time()).replace('.', '')
        # 获取鉴权对象
        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

    reply
    0
  • Cancelreply