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)
  • 相关阅读:
    VUE入门
    搭建内网穿透服务
    nacos集群配置安装
    jenkins入门
    Linux系统管理与自动化运维
    SVN
    JAR包启动
    服务器rm -rf 恢复案例 好文章
    docker入门到放弃
    CentOS7安装图形界面及报错处理
  • 原文地址:https://www.cnblogs.com/dozn/p/8582302.html
Copyright © 2011-2022 走看看