Configure browser settings in python + selenium webdriver. firefox () mode,
Webdriver. firefox () crawler requirements: (the input token can be obtained. Zip/pdf files, and then click to download)
-- The firefox browser has a Bug. A pop-up window is displayed after you click Download. You need to click OK. How can this problem be solved?
Baidu: I learned that the configuration file mimeTypes. rdf for firefox needs to be modified.
-- Enter "about: support configuration folder" in the search bar to open the folder and obtain the file address.
Add configuration content:
<RDF: Description RDF: about = "urn: mimetype: application/zip"
NC: value = "application/zip"
NC: editable = "true"
NC: fileExtensions = "zip"
NC: description = "*. zip">
<NC: handlerProp RDF: resource = "urn: mimetype: handler: application/zip"/>
</RDF: Description>
<RDF: Seq RDF: about = "urn: mimetypes: root">
<RDF: li RDF: resource = "urn: mimetype: application/zip"/>
</RDF: Seq>
===== Download now does not need to be clicked every time ====
However, when webdriver. firefox () is used, the program calls a completely new firefox, so the configuration file does not play a role.
-- The FirefoxProfile file can be added to the program (the FirefoxProfile file directory is the parent directory of mimeTypes. rdf)
Def _ init _ (self ):
Self. url = '++'
Profile = webdriver. FirefoxProfile ("C: \ Users \ USERNAME \ AppData \ Roaming \ Mozilla \ Firefox \ Profiles \ 9a71bi5y. default ")
Self. browser = webdriver. Firefox (profile)