Refresh a local web page using Python

后端 未结 5 1375
自闭症患者
自闭症患者 2021-01-04 12:24

I\'m using Python to gather some information, construct a very simple html page, save it locally and display the page in my browser using webbrowser.open(\'file:///c:/testfi

5条回答
  •  无人及你
    2021-01-04 13:10

    If you're going to need a refresh on the same tab, you'll need selenium webdriver. After installing selenium using pip, you can use the following code

        from selenium import webdriver
    import time
    import urllib
    import urllib2
    
    x=raw_input("Enter the URL")
    refreshrate=raw_input("Enter the number of seconds")
    refreshrate=int(refreshrate)
    driver = webdriver.Firefox()
    driver.get("http://"+x)
    while True:
        time.sleep(refreshrate)
        driver.refresh()
    

    This will open the url and refresh the tab every refreshrate seconds

提交回复
热议问题