Skip to content

Instantly share code, notes, and snippets.

@ErykDarnowski
Created August 9, 2023 07:33
Show Gist options
  • Save ErykDarnowski/4d70c2b0305d01fdfe525deef29903fa to your computer and use it in GitHub Desktop.
Save ErykDarnowski/4d70c2b0305d01fdfe525deef29903fa to your computer and use it in GitHub Desktop.
Open URLs from a text file
import time
import webbrowser
delay = 0.2
incognito_mode = True
input_filename = 'input.txt' # <- any URLs separated by `\n`
browser_path = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe %s' + (' --incognito' if incognito_mode else '')
# Reading lines from file anad opening each URL in the browser:
counter = 0
lines = open(input_filename, 'r').readlines()
for link in lines:
counter += 1
time.sleep(delay)
link = link.rstrip()
print(f'{counter}. {link}')
webbrowser.get(browser_path).open_new(link)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment