[python-win32] win32com: HTTP Post with WebBrowser.Navigate()

Troy Farrell troy at studyshare.net
Fri Aug 26 19:33:52 CEST 2005


Hello List!

I am trying to use win32com to automate Internet Explorer.  I am able to
instanciate my COM object, and even control IE, but using
WebBrowser.Navigate() to execute an HTTP POST request fails; the browser
always makes a GET request.  The MS KB article on doing this with VB is
here:
http://support.microsoft.com/default.aspx?kbid=174923

Possibly related bug here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;322122

I have tried to model my Python after this code, but to no avail:

---Being Python Code---

from pythoncom import Missing
import win32com.client

class Events:
  def OnDocumentComplete(self, pDisp=Missing, URL=Missing):
    """Fired when the document being navigated to reaches
ReadyState_Complete."""
    if URL == "about:blank":
      self.Navigate( dURL, Missing, Missing, PostData, Headers )


# Prepare Internet Explorer
ie = win32com.client.DispatchWithEvents( "InternetExplorer.Application.1",
Events )

dURL = "http://server/cgi-bin/test.sh"
Data = "TEST=SUCCESS"
PostData = list( Data )
Headers = "Content-Type: application/x-www-form-urlencoded\n\r"

# show it to the user
ie.Visible = True
ie.Navigate( "about:blank" )

---End Python Code---

Every time, the broser makes a GET request to the URL.  Can anyone point
me in the right direction?

Thanks.
Troy Farrell



More information about the Python-win32 mailing list