fiefox automatic download file configuration

 

def login( self):

prefile=webdriver.FirefoxProfile( 'C: \\ Users \\ anybody \\ AppData \\ Roaming \\ Mozilla \\ Firefox \\ Profiles \\ ky3cslyr.test')
#prefile.set_preference('browser .download.folderList',2)#Download path configuration : 0Desktop 1Specify path 2My download #prefile.set_preference("browser.download.dir"," Download path ")# Specify the path when selecting 2 prefile.set_preference( "browser.helperApps.neverAsk.saveToDisk", "application/octet-stream,"+

" application/vnd.ms-excel, text/csv, application/zip,application/exe")
driver=webdriver.Firefox(prefile)# browser.helperApps.neverAsk.saveToDisk does not need to confirm to download to disk, value is the specific file suffix Format, Content-Type: "application/x-www-form-urlencoded"
driver.get( self.url)
driver.maximize_window()

Commonly used encoding

 

The enctype attribute of form is the encoding method. There are two commonly used methods: application/x-www-form-urlencoded and multipart/form-data. The default is application/x-www-form-urlencoded.

  1.x-www-form-urlencoded
When the action is get, the browser uses the x-www-form-urlencoded encoding method to convert the form data into a string (name1=value1&name2=value2...), then append the string to the url, split it with ?, and load it this new url.
 

    2.multipart/form-data

 

When the action is post, the browser encapsulates the form data into the http body and sends it to the server. If there is no type=file control, use the default application/x-www-form-urlencoded. But if there is type=file, it is necessary to use multipart/form-data. The browser will divide the entire form in units of controls, and add Content-Disposition (form-data or file), Content-Type (default text/plain), name (control name) and other information to each part, and Add a delimiter (boundary).

 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325160412&siteId=291194637