Automate webpage refresh

Mike Meyer mwm at mired.org
Thu Dec 1 16:25:01 EST 2005


DarkBlue <nomail at nixmail.com> writes:
> I am trying to write a script (python2.3) which will be used 
> with linux konqueror to retrive 2 webpages alternatively every 2 minutes.
>
> My question is how can I send alternative args (the url)
> to the same invocation of konqueror which I started with
>
> def pipedreams(program, *args):
>         pid = os.fork()
>         if not pid:
>           os.execvp(program, (program,) +  args)
>           return os.wait()[0]  
>
> pipedreams("konqueror",url1)
>
> Obviously every time I call pipedreams I would open a new instance
> which is exactly what I do not want.

No, that's not at all obvious. Some browsers will notice the
previously running instance, and tell it to load the page - basically
doing exactly what you want. Some take special flags to do that.

The webbrowser module abstracts all these differences out for
you. Since it has support for Konquerer, your code should look like this:

# Untested - I don't have Konquer installed.

import webbrowser
webbrowser.open(url1)

You may have to set the BROWSER environment variable to get it to find
Konquerer.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list