2

I want to auto-download a CSV file without the download prompt. My code works until the prompt pops up. The button I click on to get the CSV uses Flash. I've got enable flash working.

mime_types = 
"application/csv,application/vnd.adobe.csv,application/vnd.fdf,
application/vnd.adobe.xdp+xml,application/vnd.adobe.csv,"
os.environ['MOZ_HEADLESS'] = '1'    
fp = webdriver.FirefoxProfile()
fp.set_preference('dom.ipc.plugins.enabled.libflashplayer.so','true')
fp.set_preference("plugin.state.flash", 2)
fp.set_preference("browser.preferences.instantApply",True)
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain, 
application/octet-stream, application/binary, text/csv, application/csv, 
application/excel, text/comma-separated-values, text/xml, 
application/xml")
fp.set_preference("browser.helperApps.alwaysAsk.force",False)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.folderList",0)
browser = webdriver.Firefox(firefox_profile=fp)

The solutions in this question have not helped. I think this may be do to it being an older version of firefox I'm currently using 68. That question is over 2yrs old. No matter what solution I try I still get the download prompt. I have a workaround where I send the enter key and it works but when I try to use task scheduler to run the script it messes up. I think it is because the task scheduler windows stays on top.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
Sophon
  • 53
  • 4

0 Answers0