Download file from url with python

We are going to use urllib.

#!/usr/bin/env python
 
import urllib
 
url = "http://server.com/files/myfile.jpg"
file = urllib.urlopen(url)
image = open(url.split('/')[-1], 'w')
image.write(file.read())
file.close()
image.close()
Categories: Python Tags: , , ,
%d bloggers like this: