/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// with default cred ccred = CredentialCache.DefaultCredentials // or special cred myCred = NetworkCredential(login,password,domaine) ccred = CredentialCache() ccred.Add(Uri(host), "NTLM", myCred) from System.Net import * def download(url,file, cred=None): wc=WebClient() if cred: wc.Credentials = cred wc.DownloadFile(url,file) def getContent(url, cred = None): wr = WebRequest.Create(url) if cred: wr.Credentials = cred rp=wr.GetResponse() r=StreamReader(rp.GetResponseStream(),Encoding.UTF8) return r.ReadToEnd()