title: Accessing password protected url from python script
body: <p>In python, I want to send a request to a url which will return some information to me. The problem is if I try to access the url from the browser, a popup box appears and asks for a username and password. I have a username and password for this url however, I don't know how to make python automatically complete these fields to access the URL. </p>
  
  <p>This is my code that returns a 401 error:</p>
  
  <pre><code>bing = "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%
  (term)s&amp;$top=50&amp;$format=json" %__function()
  results = urllib2.urlopen(bing).read()
  </code></pre>
  
  <p>EDIT: Just for clarification, the function <code>function</code> returns a variable called <code>term</code> which is the term being queried in the URL</p>