Run Python every x seconds without re-opening tabs

I am trying to make my python autoupdate code. The problem is that the code pulls four html files, which means four new tabs in the browser each time it starts.

I tried auto-updating using an answer from a similar question: What is the best way to execute a function multiple times every x seconds in Python?

import time
starttime=time.time()
while True:
  #My code here
  output_file("first.html", title="First HTML Page")
  #More code
  output_file("second.html", title="Second HTML Page")
  #Even more code


  time.sleep(60.0 - ((time.time() - starttime) % 60.0))

The problem with this method is that every minute it pulls out four more tabs - that is, after four minutes I already have 16 tabs!

Does anyone know how to auto-update using the same tabs? I would even delete the original tabs and replace them, although I imagine it is less elegant.

EDIT: Windows, IE, Firefox Chrome.

+4
6

, , , . Windows,

from subprocess import call

call("start chrome.exe") #For Google Chrome

,

call("taskkill /f /im chrome.exe")

: P

, Internet Explorer, , , , "explorer.exe". ...... .

- , .

+3

@padraicCunningham , bokeh. , . : ( ), .

, JavaScript. , , , , 4 , . , :

, Python , , webbrowser.

+2

- ( W3C - , "" ) HTML:

<meta http-equiv="refresh" content="5">

- ,

+1

, , , .

, : . , python, , , , .

destroyWindow #or something like this. But I think that is Tkinter

close() #http://www.tutorialspoint.com/python/file_close.htm
0

, get, . . , , .

, . , , 4 . dom, . :

For every x secs:
    if first time:
        open the relevant tabs
    else:
        refresh the tabs
    check if update available and do the needfull
0

x Python?

, - for loop, .

def function(n):
    for x in n:
    ~~~~~~~~~~~  # Blah, Blah, Blah. Some other code that you want
-3

Source: https://habr.com/ru/post/1599582/


All Articles