471,344 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 software developers and data experts.

Open HTML file in IE

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.

Jul 18 '07 #1
5 3894
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.
There are several ways. Assuming that IE is your default browser, just do:

import os
os.system('filename.html')

If you want to make certain that IE is launched (and not FireForx or some other
defult broswer) you can do:

os.system("start iexplore filename.html")

(at least this works on my system).

-Larry
Jul 18 '07 #2
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.Applica tion')

# 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()

Jul 18 '07 #3
On Jul 18, 3:20 am, gravey <mark_s_ro...@hotmail.comwrote:
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.
check out the os module.
os.startfile("your_htmlfile.html") should do it.

Jul 19 '07 #4
On Jul 19, 5:59 am, brad <byte8b...@gmail.comwrote:
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.Applica tion')

# 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()
Thanks to all who replied. All your approaches work but (!!) the HTML
page that I want to open contains Javascript that parses some
parameters
from the URL. The URL looks like this:

file:///C|/Temp/Google%20Maps/linktothis.htm?lat=45.0&lng=-20.0&zoom=4&type=k

The Javascript gets the URL from the Javascript location object and
parses it. I'm assuming that the location object has some kind of
Windows equivalent that might be set using win32com.client. Can anyone
shed any light on this?

Thanks

Jul 20 '07 #5
On Jul 19, 11:09 pm, gravey <mark_s_ro...@hotmail.comwrote:
The URL looks like this:

file:///C|/Temp/Google%20Maps/linktothis.htm?lat=45.0&lng=-20.0&zoom=4&type =k

The Javascript gets the URL from the Javascript location object and
parses it. I'm assuming that the location object has some kind of
Windows equivalent that might be set using win32com.client. Can anyone
shed any light on this?

Thanks
The location object is just your url. So, if the url of the page you
open in IE is parsed by javascript, then you need to use a url with
the proper information in it.
Jul 20 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jofio | last post: by
1 post views Thread by yanivmad | last post: by
3 posts views Thread by NeverLift | last post: by
29 posts views Thread by wayne | last post: by
6 posts views Thread by Tim Cowan | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.