Created
March 25, 2025 06:07
-
-
Save KnightChaser/37783e0c472136a24781c88e9e5cd4ed to your computer and use it in GitHub Desktop.
A Python3 code utilizing chrome driver to automatically send refresh(F5) to the target website as much as specified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service | |
from selenium.webdriver.chrome.options import Options | |
from webdriver_manager.chrome import ChromeDriverManager | |
from tqdm import tqdm | |
import time | |
# Configuration | |
num = 1234 # How many times? | |
url = "www.example.com" # To where? | |
# Set up Chrome options (use headless mode if you don't need a visible browser) | |
chrome_options = Options() | |
chrome_options.add_argument("--headless") # Optional: remove if you need a visible browser | |
chrome_options.add_argument("--disable-gpu") | |
# Initialize the Chrome driver using webdriver-manager | |
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) | |
# Loop with tqdm to track progress | |
for i in tqdm(range(num), desc="Accessing pages"): | |
try: | |
driver.get(url) | |
# Optional: wait for a few seconds to let the page load fully (adjust as needed) | |
time.sleep(0.75) | |
# print(f"Request {i+1}: Page title - {driver.title}") | |
except Exception as e: | |
print(f"Request {i+1}: Failed - {e}") | |
# Cleanup: close the browser when done | |
driver.quit() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment