def download_url(url):
 import urllib2
 try:
  resp = urllib2.urlopen(url)
  headers = resp.info()
 except urllib2.URLError as e:
  print ('Error downloading %s' % url)
  return None
 return resp.read()

def download_url ( url ) : import urllib2 try : resp = urllib2 . urlopen ( url ) headers = resp . info ( ) except urllib2 . URLError as e : print ( 'Error downloading %s' % url ) return None return resp . read ( )
download a file from url to filename .