2

I am working on a scraping project where sometimes visiting an URL downloads file automatically. For that I have specified the fixed download path like below -

    options = webdriver.ChromeOptions()
    prefs = {"download.default_directory": "/home/user/Documents/project/downloads"}
    options.add_experimental_option("prefs", prefs)
    options.add_argument("--headless")
    return webdriver.Chrome(options=options)

This used to work like a week ago, but today the file always gets downloaded to current directory instead of the specified path. What could be causing this to happen? Am I missing something :(

You can try this URL as an example.

Thanks

  • Use `request` to download the file. See [downloading file using requests](https://stackoverflow.com/a/16696317/14900791). – Jurakin Mar 16 '23 at 11:41
  • There is no issue with file being downloaded. Selenium is downloading file properly. The issue is - its not being downloaded in the `right folder` but instead in the current directory. – Pratik Ghodke Mar 17 '23 at 07:05

0 Answers0