[Tutor] How to open IE7 to a certain URL?

Tim Golden mail at timgolden.me.uk
Fri Feb 29 14:07:20 CET 2008

Dick Moores wrote:
> I keep missing a certain weekly program on my local NPR station. My 
> idea is to record it using software I have, Easy Hi-Q Recorder. I can 
> set it to start recording when the program starts, 8pm, but I need to 
> have the program playing on my computer. The URL for the station's 
> audio is http://www.kuow.org/real.ram .
> I've got this so far:
> #!/usr/bin/env python
> #coding=utf-8
> import time
> b = '20:00:00'
> while True:
>      a = time.strftime('%H:%M:%S')
>      time.sleep(0.5)
>      if a == b:
>          print "TIME!"
>          break
> Obviously, I need to replace the  'print "TIME"'  line with something 
> that will open IE7 to http://www.kuow.org/real.ram . But what?

Sidestepping slightly, the natural way to open a URL using
whatever's set up to do so is with os.startfile:

import os

os.startfile ("http://whatever...ram")


I was going to say that, to use IE7 explicitly, you should
use the webbrowser module. But then I realised that, for
reasons which I'm sure are extremely good but which elude
me for now, iexplorer is not one of the registered browsers.

As a fallback, you can look for its apppath entry in the registry
and use subprocess to call that.


More information about the Tutor mailing list