In [1]:
import requests
import os

In [2]:
url_image = 'https://www.python.org/static/community_logos/python-logo.png'

In [3]:
r_image = requests.get(url_image)

In [4]:
print(r_image.headers['Content-Type'])


image/png

In [5]:
filename_image = os.path.basename(url_image)
print(filename_image)


python-logo.png

In [6]:
with open('data/temp/' + filename_image, 'wb') as f:
    f.write(r_image.content)

In [7]:
url_zip = 'http://www.post.japanpost.jp/zipcode/dl/oogaki/zip/13tokyo.zip'

In [8]:
r_zip = requests.get(url_zip)

In [9]:
print(r_zip.headers['Content-Type'])


application/zip

In [10]:
filename_zip = os.path.basename(url_zip)
print(filename_zip)


13tokyo.zip

In [11]:
with open('data/temp/' + filename_zip, 'wb') as f:
    f.write(r_zip.content)