Skip to content

Instantly share code, notes, and snippets.

@stefanschmidt
Created April 14, 2022 20:42
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 stefanschmidt/0c35cb275d671014ebe6c1d322518318 to your computer and use it in GitHub Desktop.
Save stefanschmidt/0c35cb275d671014ebe6c1d322518318 to your computer and use it in GitHub Desktop.
Download file in headless Firefox with Selenium and geckodriver on macOS
# install requirements
# brew install python@3.10 # Python 3.7+ required
# brew install geckodriver # To access Firefox
# pip install --upgrade selenium
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
browser = webdriver.Firefox(options=options)
browser.get("http://pypi.python.org/pypi/selenium")
browser.find_element_by_partial_link_text("Download files").click()
browser.find_element_by_partial_link_text("selenium-4.1.3-py3-none-any.whl").click()
browser.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment