Can't store downloaded files in their concerning folders

前端 未结 3 1064
再見小時候
再見小時候 2021-01-12 08:02

I\'ve written a script in python in combination with selenium to download few document files (ending with .doc) from a webpage. The reason I do not wish to use request

3条回答
  •  无人及你
    2021-01-12 08:09

    Use this code while declaring the Driver object (This is for Java, Python will also have a similar way to accomplish it) This will download the file to the specified location every time.

        //Create preference object
        HashMap chromePrefs = new HashMap();   
        //Set Download path  
        chromePrefs.put("download.default_directory","C:\\Reports\\AutomaionDownloads");
            chromePrefs.put("download.directory_upgrade", true);
            ChromeOptions options = new ChromeOptions();
            options.setExperimentalOption("prefs", chromePrefs);    
            //Call the Chrome Driver
            WebDriver driver = new ChromeDriver(options); 
    

提交回复
热议问题