code: def download_url(url):
      '''download a URL and return the content'''
      if sys.version_info.major < 3:
          from urllib2 import urlopen as url_open
          from urllib2 import URLError as url_error
      else:
          from urllib.request import urlopen as url_open
          from urllib.error import URLError as url_error
      try:
          resp = url_open(url)
          headers = resp.info()
      except url_error as e:
          print('Error downloading %s' % url)
          return None
      return resp.read(f download_url(url):
      '''download a URL and return the content'''
      if sys.version_info.major < 3:
          from urllib2 import urlopen as url_open
          from urllib2 import URLError as url_error
      else:
          from urllib.request import urlopen as url_open
          from urllib.error import URLError as url_error
      try:
          resp = url_open(url)
          headers = resp.info()
      except url_error as e:
          print('Error downloading %s' % url)
          return None
      return resp.read()
docs: download a URL and return the content