Posted By

manatlan on 09/14/09


Tagged

web ironpython ntlm


Versions (?)

IronPython : url request (thru ntlm proxy too)


 / Published in: Python
 

  1. // with default cred
  2. ccred = CredentialCache.DefaultCredentials
  3.  
  4. // or special cred
  5. myCred = NetworkCredential(login,password,domaine)
  6. ccred = CredentialCache()
  7. ccred.Add(Uri(host), "NTLM", myCred)
  8.  
  9.  
  10. from System.Net import *
  11.  
  12. def download(url,file, cred=None):
  13. wc=WebClient()
  14. if cred:
  15. wc.Credentials = cred
  16. wc.DownloadFile(url,file)
  17.  
  18. def getContent(url, cred = None):
  19. wr = WebRequest.Create(url)
  20. if cred:
  21. wr.Credentials = cred
  22. rp=wr.GetResponse()
  23. r=StreamReader(rp.GetResponseStream(),Encoding.UTF8)
  24. return r.ReadToEnd()

Report this snippet  

You need to login to post a comment.