Open HTML file in IE

brad byte8bits at gmail.com
Wed Jul 18 15:59:04 EDT 2007


gravey wrote:
> Hello.
> 
> Apologies if this is a basic question, but I want to open a HTML
> file from my local drive (is generated by another Python script)
> in Internet Explorer. I've had a look at the webbrowser module and
> this doesn't seem to be what I need. Any help much appreciated.

You may try something like this example:

import time
import win32com.client

wie = win32com.client.Dispatch('InternetExplorer.Application')

# Make IE Window Visible.
wie.Visible = 1

# Open this URL
wie.Navigate('www.your_url.com')

# Print 'Busy' while Busy.
while wie.Busy:
     print 'Busy'

# Sleep 2 secs, then go home.
time.sleep(2)
wie.GoHome()

# Sleep 2 secs, then go back.
time.sleep(2)
wie.GoBack()

# Refresh the page
time.sleep(2)
wie.Refresh()

# Close IE Window
time.sleep(2)
wie.Quit()




More information about the Python-list mailing list