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?
How to open html files from python using internet explorer
Collapse
X
-
-
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 BaseHTTPRequest Handler but it seems that it doesn't load the references to other assets (jpg, swf, etc). Something like:
from BaseHTTPServer import HTTPServer, BaseHTTPRequest Handler
import os
class RequestHandler( BaseHTTPRequest Handler):
def _writeheaders(s elf):
self.send_respo nse(200)
self.send_heade r('Content_type ', 'text/html')
self.end_header s()
def do_HEAD(self):
self._writehead ers()
def do_GET(self):
self._writehead ers()
self.wfile.writ e("""<html>
<head>
<title>Qualit y insurance</title>
....
<link href="Assets/text.css" rel="stylesheet " type="text/css">
...
<p><img name="SplashIma ge" src="page1.jpg" width="600" </p>
...
</body>
</html>""")
serveraddr = ('', 8765)
srvr = HTTPServer(serv eraddr, RequestHandler)
srvr.serve_fore ver()
So, it has problems loading page1.jpg, It doesn't appear in my web browser, IE or Mozilla.
Thanks.Comment
Comment