3
I’m using Selenium (Python) to fetch some data from a site, at a given time I access a link that downloads a file. How to configure the webdriver (Firefox) to automatically accept the download, without which I need to click download?
3
I’m using Selenium (Python) to fetch some data from a site, at a given time I access a link that downloads a file. How to configure the webdriver (Firefox) to automatically accept the download, without which I need to click download?
3
Use FirefoxProfile
to configure your Firefox before instantiating browser:
from selenium import webdriver
import os
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList",2)
firefox_profile.set_preference("browser.download.manager.showWhenStarting",False)
firefox_profile.set_preference("browser.download.dir", os.getcwd())
firefox_profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
browser = Firefox(firefox_profile = firefox_profile)
Browser other questions tagged python selenium selenium-webdriver web-scraping
You are not signed in. Login or sign up in order to post.
Thank you, it worked perfectly!
– Wellington Araujo Nogueira
See here how the site works. Thank you!
– Leonel Sanches da Silva
I just wanted to know if you can help me on another rs thing, the file being downloaded. Is there any set_preference that I can rename it?
– Wellington Araujo Nogueira
No. You will possibly have to download the file and then rename using
os
.– Leonel Sanches da Silva