Spaces:
Build error
Build error
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}") |