-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen_links.py
More file actions
28 lines (22 loc) · 827 Bytes
/
open_links.py
File metadata and controls
28 lines (22 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import webbrowser
import logging
import time
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def open_links_in_browser(links, delay=2):
for link in links:
try:
logger.info(f"Opening link: {link}")
webbrowser.open_new_tab(link)
time.sleep(delay)
except Exception as e:
logger.error(f"Failed to open link {link}: {e}")
if __name__ == "__main__":
# Replace the sample links with your desired URLs to open
sample_links = [
"https://www.github.com",
"https://www.google.com",
"https://www.youtube.com"
]
# Time delay of 3 seconds between opening each link to not overwhelm the browser
open_links_in_browser(sample_links, delay=3)