This script uses Selenium to continuously refresh a webpage as fast as possible, with performance optimizations like disabling images and using headless mode.
Ensure you have the following installed:
- Python 3.7 or higher
pip
(Python package manager)
# Replace with your repository URL if applicable
git clone https://github.com/Boutzi/page-refresher.git
cd page-refresher
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install the required Python libraries using the requirements.txt
file:
pip install --upgrade pip
pip install -r requirements.txt
selenium==4.27.1
webdriver-manager==4.0.2
-
Edit the Script: Open the
main.py
file and replacehttps://your-website
with the URL of the webpage you want to refresh. -
Run the Script:
python main.py
-
Output: The script will print how long each page refresh takes, for example:
Page refreshed in 0.53 seconds Page refreshed in 0.50 seconds
-
Stop the Script:
Press
ESCAPE
orCTRL + C
To further optimize performance, uncomment the following lines in the script:
prefs = {"profile.managed_default_content_settings.images": 2}
options.add_experimental_option("prefs", prefs)
The script refreshes the page as quickly as possible. If you want to add a delay between refreshes, modify the loop in main()
:
while True:
start_time = time.time()
refreshPage(driver)
end_time = time.time()
print(f"Page refreshed in {end_time - start_time:.2f} seconds")
time.sleep(1) # Add a 1-second delay
Ensure you have the correct version of Chrome installed and that webdriver-manager
is up to date:
pip install --upgrade webdriver-manager
If you see missing dependencies, ensure the virtual environment is active:
source venv/bin/activate # On Windows: venv\Scripts\activate
This project is licensed under the MIT License. See the LICENSE file for details.