How to open html files from python using internet explorer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dynamo
    New Member
    • Apr 2007
    • 51

    How to open html files from python using internet explorer

    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?
  • oana
    New Member
    • May 2007
    • 2

    #2
    Hi,
    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.

    Comment

    • ghostdog74
      Recognized Expert Contributor
      • Apr 2006
      • 511

      #3
      check out the webbrowser module

      Comment

      • oana
        New Member
        • May 2007
        • 2

        #4
        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

        Working...