title: Python NTLM login
body: <p>I am trying to pull information from a url that requires NTLM login.</p>
  
  <p>I originaly received 401 error and after some tweaks have been able to pull the page stating that I have input invalid credentials.</p>
  
  <p>The username and password are correct yet I cannot get past the invalid credentials page.</p>
  
  <p><strong>Lgn2.py</strong>:</p>
  
  <pre><code>import urllib2
  import HTTPNtlmAuthHandler
  
  login = open('c:/temp/login.txt')
  open = login.read()
  to = open.split()
  user = str(to[0])
  password = str(to[1])
  
  url = "http://INSERT URL HERE.com/"
  passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
  passman.add_password(None, url, user, password)
  auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)
  
  
  opener = urllib2.build_opener(auth_NTLM)
  urllib2.install_opener(opener)
  
  
  response = urllib2.urlopen(url)
  print(response.read())
  </code></pre>
  
  <p>I have a username including a \ using the method above I do not get a double backslash in the name when it prints. Should I keep it to where print will have the double backslash in the name as apposed to exactly as the txt file has the username spelled?</p>
  
  <p>The txt file is just a txt document with only:  <strong>domain\user\name password</strong>.</p>
  
  <p>The second backslash in the middle of username would be part of the username.</p>
  
  <p>Any help would be appreciated.</p>