0

I'm creating a script that downloads and shifts pdfs into different specific directories based on a search. I have code that generates the folder and subfolders recursively, I simply need to be able to download the pdfs into that file. I'm wondering how I can dynamically change the download location before I download each file in Selenium without having to start a new driver session. I could use os commands to move the files, but their names are a convoluted mess so having them go directly into the specified folder is preferable. Thank you!

2 Answers2

0

Simply set option, prompt for download as true. it will ask you every time where to save files. then you can enter desired download location.

try below code to launch browser

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_experimental_option('prefs', {"download.prompt_for_download": True})

driver = webdriver.Chrome(chrome_options=options)
Adrian W
  • 4,563
  • 11
  • 38
  • 52
  • I get how to initiate a driver with a custom download directory. However, my script has me downloading files and I need them to be downloaded into different directories. I must change the download directory without starting up a new driver session. Do you know how to do this? – scoobySnax Jul 27 '21 at 21:39
  • once you initiate a driver with above code it will ask you each time where to save file, then you can enter your desired download path. – Ashok Kakade Jul 28 '21 at 05:44
  • check this https://stackoverflow.com/questions/53023853/change-chromeoptions-in-an-existing-webdriver – Ashok Kakade Jul 28 '21 at 06:20
-2

try this it will

pipq10 '''''()''''' ()qlqst (0)piyQ