From Selenium Import Webdriver
From Selenium Import Webdriver
try:
iteration = 1
while True: # Run indefinitely
for url in urls:
print(f"Iteration {iteration}: Opening {url}")
try:
driver.get(url) # Load the URL
print(f"Final URL: {driver.current_url}")
# Wait for page load (confirm page is ready)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.TAG_NAME, "body"))
)
print("Page loaded successfully")
driver.delete_all_cookies() # Clear cookies to simulate a new
session
time.sleep(15) # Wait 15 seconds before reloading
except Exception as e:
print(f"Failed to load {url}: {type(e).__name__} - {str(e)}")
continue
iteration += 1
except KeyboardInterrupt:
print("\nScript stopped by user (Ctrl+C). Closing browser.")
finally:
driver.quit() # Close browser only when user stops the script