Spaces:
Build error
Build error
File size: 778 Bytes
18c46ab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import time
import webbrowser
# File containing the list of URLs (one URL per line)
file_path = "urls.txt"
try:
# Open the file and read the URLs
with open(file_path, "r") as file:
urls = file.readlines()
# Open each URL with a delay of 3 seconds
for url in urls:
url = url.strip() # Remove any leading/trailing whitespace
if url: # Check if the URL is not empty
print(f"Opening: {url}")
webbrowser.open(url) # Open the URL in the default browser
time.sleep(3) # Wait for 3 seconds before opening the next URL
print("All URLs have been opened.")
except FileNotFoundError:
print(f"Error: The file '{file_path}' was not found.")
except Exception as e:
print(f"An error occurred: {e}") |