title: How to use urllib with username/password authentication in python 3?
body: <p>Here is my problem with urllib in python 3.</p>
  
  <p>I wrote a piece of code which works well in Python 2.7 and is using urllib2. It goes to the page on Internet (which requires authorization) and grabs me the info from that page.</p>
  
  <p>The real problem for me is that I can't make my code working in python 3.4 because there is no urllib2, and urllib works differently; even after few hours of googling and reading I got nothing. So if somebody can help me to solve this, I'd really appreciate that help.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    request = urllib2.Request('http://mysite/admin/index.cgi?index=127')
      base64string = base64.encodestring('%s:%s' % ('login', 'password')).replace('\n', '')
      request.add_header("Authorization", "Basic %s" % base64string)
      result = urllib2.urlopen(request)
      resulttext = result.read()
  </code></pre>