Created
November 19, 2021 15:58
-
-
Save ashhadulislam/bcd8cadfc5bd7b23c44396db83b4a539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import from selenium | |
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary | |
binary = '/Applications/Tor Browser.app/Contents/MacOS/firefox' | |
# the location of firefox package inside Tor | |
if os.path.exists(binary) is False: | |
raise ValueError("The binary path to Tor firefox does not exist.") | |
firefox_binary = FirefoxBinary(binary) | |
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 = None | |
browser = get_browser(binary=firefox_binary) | |
# click on connect to connect the tor browser to the remote nodes | |
browser.find_element_by_xpath('//*[@id="connectButton"]').click() | |
time.sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment