from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
# List of URLs to open
urls = ["https://www.profitableratecpm.com/xn5nkg4ni?
key=f45f5ee07e0d4bd8984e4b74f6144a91"]
# Set up Chrome options
chrome_options = Options()
chrome_options.add_argument('--log-level=3') # Suppress non-critical logs
chrome_options.add_argument('--incognito') # Use incognito mode for fresh sessions
# chrome_options.add_argument("--headless") # Uncomment for headless mode if
desired
# Initialize the WebDriver
driver = webdriver.Chrome(options=chrome_options)
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