By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

How to open html files from python using internet explorer

P: 51
Hi everyone.I am trying to write a program that will open a html file with internet explorer the normal way.I don't just want to display the contents of the file in python like readlines() or read() does.i want to actually open the file as a web page.GhostDog gave me some tips on how to do this using modules like urllib and urllib2.But i dont think i understand the documentation properly as i have not been able to use the functions successfully.I also suspect that they do what read() does which is to display the contents of the file as a string.Can anyone help?
Apr 27 '07 #1
Share this Question
Share on Google+
3 Replies

P: 2
I kind of need that too. More than that.. I need to decrypt on the fly a html page and view it in mozilla. I will do some research on the urllib. If you find something interesenting please post a reply.
May 15 '07 #2

Expert 100+
P: 511
check out the webbrowser module
May 15 '07 #3

P: 2
Well.. that doesn't help me. I need to open a page in a web browser based on the source(text) of that html.
I tried the BaseHTTPRequestHandler but it seems that it doesn't load the references to other assets (jpg, swf, etc). Something like:

from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import os

class RequestHandler(BaseHTTPRequestHandler):

def _writeheaders(self):
self.send_header('Content_type', 'text/html')

def do_HEAD(self):

def do_GET(self):
<title>Quality insurance</title>
<link href="Assets/text.css" rel="stylesheet" type="text/css">
<p><img name="SplashImage" src="page1.jpg" width="600" </p>

serveraddr = ('', 8765)
srvr = HTTPServer(serveraddr, RequestHandler)

So, it has problems loading page1.jpg, It doesn't appear in my web browser, IE or Mozilla.

May 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.