Skip to content

Instantly share code, notes, and snippets.

@ashhadulislam
Last active November 19, 2021 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashhadulislam/e68e7bb9091d5d775342886a1568d8d5 to your computer and use it in GitHub Desktop.
Save ashhadulislam/e68e7bb9091d5d775342886a1568d8d5 to your computer and use it in GitHub Desktop.
# import from selenium
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = '/Applications/Tor Browser.app/Contents/MacOS/firefox'
# the location of
if os.path.exists(binary) is False:
raise ValueError("The binary path to Tor firefox does not exist.")
firefox_binary = FirefoxBinary(binary)
browser = None
def get_browser(binary=None,options=None):
global browser
# only one instance of a browser opens, remove global for multiple instances
if not browser:
browser = webdriver.Firefox(firefox_binary=binary,options=options)
return browser
browser = get_browser(binary=firefox_binary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment