Created
October 7, 2014 22:31
-
-
Save quapka/4bbcf76aee49cf914f2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib, cStringIO | |
import re | |
PATH = 'some path' | |
def download_file(path): | |
print "Attempting to download file from:" | |
print "URL: {}".format( path ) | |
_file = cStringIO.StringIO(urllib.urlopen( path ).read()) | |
if _file: | |
print "... successfully read to buffer" | |
else: | |
print "ERROR while trying to read from:" | |
print "URL: {}".format( path ) | |
return | |
filename = path[::-1].split('/')[0][::-1] | |
with open(filename, 'w') as f: | |
f.write( _file.getvalue() ) | |
print "+++ {}".format( filename ) | |
_file.close() | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment