Return to Snippet

Revision: 17754
at September 14, 2009 03:20 by manatlan


Initial Code
// 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()

Initial URL

                                

Initial Description

                                

Initial Title
IronPython : url request (thru ntlm proxy too)

Initial Tags
web

Initial Language
Python