2

The project directory looks like:

project
 -temp
 -program.py

This code downloads the file but does not download the file in the desired folder. I want the downloaded file in temp folder.

program.py

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

profile = webdriver.FirefoxProfile()

profile.set_preference("browser.download.folderList",2)
# 0 for desktop
# 1 for default download folder
# 2 for specific folder
# You can specify directory by using profile.set_preference("browser.download.dir","<>")
profile.set_preference("browser.download.dir","temp/")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
profile.set_preference("browser.helperApps.alwaysAsk.force", False);
Atom Store
  • 961
  • 1
  • 11
  • 35

1 Answers1

0

okay this is not the exact solution, but it's a workaround.

what if we just move the file from where it got downloaded to temp folder ?

from pathlib import Path

Path("path/to/current/file.foo").rename("path/to/new/destination/for/file.foo")

see here to learn more how we can move a file in Python.

cruisepandey
  • 28,520
  • 6
  • 20
  • 38