책 내용에 대한 무단배포 방지를 위해 최소한으로 정리
from urllib.request import urlopen
imgurl = 'http://www.epaiai.com/img_sample.jpg'
imgname = imgurl.split('/')[-1]
try:
with urlopen(imgurl) as f:
with open(imgname, 'wb') as h:
img = f.read()
h.write(img)
except Exception as e:
print(e)
Comments