472,973 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,973 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 3997
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jofio | last post by:
Hello, I am a newbie in PHP and I am enthusiastically trying out things. I've just replaced my index.html ( file with index.php
1
by: yanivmad | last post by:
hi I like to ask if there any option to control the html files?!? I have some HTML files at my web site that use one "Help.htm" file for all the pages {I use the "window.open(.... " option at...
1
by: yanivmad | last post by:
hi I like to ask if there any option to control the html files?!? I have some HTML files at my web site that use one "Help.htm" file for all the pages {I use the "window.open(.... " option at...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
29
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
6
by: Tim Cowan | last post by:
Hi I have the following code to write an error file and it is supposed to open the HTML file in a browser when an error occurs. It creates the file Ok but doesn't open the new browser and doesn't...
1
by: frontline1 | last post by:
hello im trying to open html file with fstream clas (foo.open("test.html",ios::in) but with no luck , but when i try to open in this way *.txt file , i is working great . my question is , how...
1
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
1
by: Charlie | last post by:
I am trying to make an XMLHttpRequest which violates the default "same- origin"policy in Firefox. I checked the archives and found a method that should work but it does not. Below is the test code...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.