zoukankan      html  css  js  c++  java
  • python+selenium webdriver.firefox()方式配置浏览器设置

    webdriver.firefox() 爬虫需求:  (其实是输入参数可获取.zip/pdf 文件,然后点击下载)

    ——但是firefox浏览器有Bug,点击下载之后会有弹出窗口,需要你点击确定,这怎么能成,所以

    百度一把:得知需要修改firefox的配置文件mimeTypes.rdf

    ——搜索栏输入:about:support  配置文件夹—》打开文件夹—》获取文件地址

    添加配置内容:

    <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>

    =====现在下载不需要每次都点击了=====

    但是:使用webdriver.firefox()时,程序调用的是一个全新的firefox,所以配置文件并没有起到作用

    ——程序中可添加FirefoxProfile文件来支持 (FirefoxProfile文件目录就是mimeTypes.rdf的上级目录)

    def __init__(self):
    self.url = '+++++++++++++'
    profile=webdriver.FirefoxProfile("C:Users用户名AppDataRoamingMozillaFirefoxProfiles9a71bi5y.default")
    self.browser = webdriver.Firefox(profile)
  • 相关阅读:
    JVM调优--常用JVM监控工具使用
    jvm启动常用参数配置
    公钥和私钥原理
    tcp三次握手四次挥手
    内存泄漏和内存溢出
    hashmap解析
    Visual C++ 6.0 断点调试记录
    C++中输入一组不确定长度的数
    异或
    NULL与nullptr
  • 原文地址:https://www.cnblogs.com/dozn/p/8582302.html
Copyright © 2011-2022 走看看