title: Download a file providing username and password using Python
body: <p>My file named as 'blueberry.jpg' begins downloading, when I click on the following url manually provided that the username and password are typed when asked:
  <a href="http://example.com/test/file" rel="nofollow">http://example.com/blueberry/download</a></p>
  
  <p>How can I make that happen using Python?</p>
  
  <pre><code>import urllib.request
  
  url = 'http://example.com/blueberry/download'
  
  data = urllib.request.urlopen(url).read()
  
  fo = open('E:\\quail\\' + url.split('/')[1] + '.jpg', 'w')
  print (data, file = fo)
  
  fo.close()
  </code></pre>
  
  <p>However above program does not write the required file, how can I provide the required username and password?</p>