[python-win32] authentication proxy and download
Christophe Deze
christophedeze at wanadoo.fr
Mon Mar 1 19:57:21 CET 2010
sorry for the monolog .. :D
i'm closed to succeed but how to retrieve transparently user and pwd ?
import win32inet
hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0)
h =
win32inet.InternetOpenUrl(hinternet,'http://downloads.sourceforge.net/sevenzip/7z465.msi')
win32inet.InternetSetOption(h,43,user)
win32inet.InternetSetOption(h, 44,pwd)
chunks = []
while 1:
chunk = win32inet.InternetReadFile(h, 1024)
if not chunk:
break
chunks.append(chunk)
data = ''.join(chunks)
f = open('test.msi', 'wb')
f.write(data)
maybe should I use ctype like here :
http://stackoverflow.com/questions/1078939/id-like-to-call-the-windows-c-function-winhttpgetproxyforurl-from-python-can
thanks for reading
Le 01/03/2010 18:59, Christophe Deze a écrit :
> it should look like that ???
>
> import win32inet
> hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0)
> win32inet.InternetSetOption(INTERNET_OPTION_PROXY_PASSWORD,SizeofOtion)
> win32inet.InternetSetOption(INTERNET_OPTION_PROXY_USERNAME,SizeofOtion)
> #h = win32inet.InternetConnect(hinternet,'www.google.fr',80,'','',3,0)
>
> h =
> win32inet.InternetOpenUrl(hinternet,'http://downloads.sourceforge.net/sevenzip/7z465.msi')
>
> data =win32inet.InternetReadFile(hinternet,sizeOfFile)
>
>
> Le 01/03/2010 18:03, Christophe Deze a écrit :
>> hello
>>
>> I wrote a windows app that must download file
>> it works fine with urllib.urlretrieve.
>>
>> But I want to download file through a proxy with NTLM
>> (samba)authentication .
>> I want to use windows sessions credential transparently, as IE and
>> Firefox do well...
>>
>> I don't think that urllib(2) can do this.
>>
>> But maybe a win32 API ?
>>
>> http://docs.activestate.com/activepython/2.5/pywin32/win32inet.html
>> http://msdn.microsoft.com/en-us/library/aa384220%28VS.85%29.aspx
>>
>>
>> What do you think of this ?
>> any idea ?
>>
>> thanks
>>
>>
>>
>>
>>
>> _______________________________________________
>> python-win32 mailing list
>> python-win32 at python.org
>> http://mail.python.org/mailman/listinfo/python-win32
>>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100301/bb5ee104/attachment.html>
More information about the python-win32
mailing list