html - Refresh a local web page using Python -


i'm using python gather information, construct simple html page, save locally , display page in browser using webbrowser.open('file:///c:/testfile.html'). check new information every minute. if information changes, rewrite local html file , reload displayed page.

the problem webbrowser.open opens new tab in browser every time run it. how refresh page rather reopen it? tried new=0, new=1 , new=2, same thing. using controller() doesn't work better.

i suppose add < meta http-equiv="refresh" content="60" > < head > section of html page trigger refresh every minute whether or not content changed, prefer finding better way.

exact time interval not important.

python 2.7.2, chrome 26.0.1410.64 m, windows 7 64.

if you're going need refresh on same tab, you'll need selenium webdriver. after installing selenium using pip, can use following code

    selenium import webdriver import time import urllib import urllib2  x=raw_input("enter url") refreshrate=raw_input("enter number of seconds") refreshrate=int(refreshrate) driver = webdriver.firefox() driver.get("http://"+x) while true:     time.sleep(refreshrate)     driver.refresh() 

this open url , refresh tab every refreshrate seconds


Comments