faqts : Computers : Programming : Languages : Python : Common Problems : COM

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

76 of 82 people (93%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Can I use Python to run Internet Explorer and control it via COM?

Jul 5th, 2000 05:38
unknown unknown, Roger Upole, Mark Hammond


Here's a small sample of how to navigate to a URL.
>>> import win32com.client
>>> x=win32com.client.Dispatch('InternetExplorer.Application.1')
>>> x.Visible=1
>>> x.Navigate('http://www.python.org')
If you run makepy on Microsoft Internet Controls, the file generated in
Python\win32com\genpy will show all the properties and methods available 
for this object.

This will work fine to control IE.

However, look in "win32com\client\__init__.py", and look for the
"DispatchWithEvents" docstring - this has an example that uses IE to 
both control it, and respond to events (such as URL load completed, etc)