I'm trying to use a feature of the Microsoft WinHttp library that has been exposed by the developers of Win32com. Unfortunately most of the library does not seem to be documented and there are no example of the correct way to use the win32inet features via the win32com library.
This is what I have so far:
import win32inet
hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0)
# Does not work!!!
proxy = win32inet.WinHttpGetProxyForUrl( hinternet, u"http://www.foo.com", 0 )
As you can see, all I am trying to do is use the win32inet feature to find out which proxy is the appropriate one to use for a given URL, int his case foo.com.
Can you help me correct the syntax of the last line? MSN has some good documentation for the function being wrapped but the args do not seem to map the to those of the python library perfectly.
The fixed version of this script should:
Be able to look up which proxy to use for any given URL.
It should always do exactly what Internet Explorer would do (i.e. use the same proxy)
It should be valid on any valid Windows XP set-up. That means it should work with an explicitly configured proxy and also no proxy at all.
It only needs to work on Windows XP 32bit with Python 2.4.4. It can use any official released version of win32com.
I'm using Python2.4.4 with Win32Com on Windows XP.
UPDATE 0:
OR... can you give me an alternative implementation in cTypes? As long as I can make it work I'm happy!