Use BasicAuthHandler to provide a password instead:
import urllib2 passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, "http://casfcddb.xxx.com", "char_user", "char_pwd") auth_handler = urllib2.HTTPBasicAuthHandler(passman) opener = urllib2.build_opener(auth_handler) urllib2.install_opener(opener) urllib2.urlopen("http://casfcddb.xxx.com")
or using the query library:
import requests requests.get("http://casfcddb.xxx.com", auth=('char_user', 'char_pwd'))
source share