Lot of people don't realize that old syntax for specifying username and password in URL works in urllib.urlopen. It doesn't appear the username or password require any encoding, except perhaps if the password included an @ symbol.
It's a pure python library, installing is as easy as easy_install requests or pip install requests. It has an extremely simple and easy to use API, and it fixes bugs in urllib2 so you don't have to. Don't make your life harder because of silly self-imposed requirements.
if you define a url, username, password, and some post-data, this should work in Python2...
example from official Python docs showing Basic Auth in urllib2: * http://docs.python.org/release/2.6/howto/urllib2.html
full tutorial on Basic Authentication using urllib2: * http://www.voidspace.org.uk/python/articles/authentication.shtml
Hackish workaround works:
Lot of people don't realize that old syntax for specifying username and password in URL works in urllib.urlopen. It doesn't appear the username or password require any encoding, except perhaps if the password included an @ symbol.
Seriously, just use
requests
:It's a pure python library, installing is as easy as
easy_install requests
orpip install requests
. It has an extremely simple and easy to use API, and it fixes bugs inurllib2
so you don't have to. Don't make your life harder because of silly self-imposed requirements.