Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium firefox配置文件从不要求不工作_Python_Firefox_Selenium - Fatal编程技术网

Python Selenium firefox配置文件从不要求不工作

Python Selenium firefox配置文件从不要求不工作,python,firefox,selenium,Python,Firefox,Selenium,我正在尝试保存一个没有弹出框的csv文件。我通过以下链接了解我的mime: 我甚至添加了mimeTypes.rdf文件中的所有NC_值。但是,它似乎不起作用 profile = webdriver.FirefoxProfile() profile.set_preference('browser.download.folderList', 2) profile.set_preference('browser.download.manager.showWhenStarting', False) p

我正在尝试保存一个没有弹出框的csv文件。我通过以下链接了解我的mime:

我甚至添加了mimeTypes.rdf文件中的所有NC_值。但是,它似乎不起作用

profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2)
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', os.getcwd())
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'irc,ircs,webcal,application/csv,application/download,application/pdf')
mimeTypes.rdf

<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <RDF:Seq RDF:about="urn:schemes:root">
    <RDF:li RDF:resource="urn:scheme:webcal"/>
    <RDF:li RDF:resource="urn:scheme:ircs"/>
    <RDF:li RDF:resource="urn:scheme:mailto"/>
    <RDF:li RDF:resource="urn:scheme:irc"/>
  </RDF:Seq>
  <RDF:Description RDF:about="urn:scheme:mailto"
                   NC:value="mailto">
    <NC:handlerProp RDF:resource="urn:scheme:handler:mailto"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:handler:web:https://30boxes.com/external/widget?refer=ff&amp;url=%s"
                   NC:prettyName="30 Boxes"
                   NC:uriTemplate="https://30boxes.com/external/widget?refer=ff&amp;url=%s" />
  <RDF:Description RDF:about="urn:scheme:irc"
                   NC:value="irc">
    <NC:handlerProp RDF:resource="urn:scheme:handler:irc"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:scheme:handler:mailto"
                   NC:useSystemDefault="true"
                   NC:alwaysAsk="false">
    <NC:possibleApplication RDF:resource="urn:handler:web:https://compose.mail.yahoo.com/?To=%s"/>
    <NC:possibleApplication RDF:resource="urn:handler:web:https://mail.google.com/mail/?extsrc=mailto&amp;url=%s"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:handler:web:https://mail.google.com/mail/?extsrc=mailto&amp;url=%s"
                   NC:prettyName="Gmail"
                   NC:uriTemplate="https://mail.google.com/mail/?extsrc=mailto&amp;url=%s" />
  <RDF:Description RDF:about="urn:scheme:handler:webcal"
                   NC:useSystemDefault="true"
                   NC:alwaysAsk="true">
    <NC:possibleApplication RDF:resource="urn:handler:web:https://30boxes.com/external/widget?refer=ff&amp;url=%s"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:mimetype:application/pdf"
                   NC:value="application/pdf">
    <NC:handlerProp RDF:resource="urn:mimetype:handler:application/pdf"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:scheme:ircs"
                   NC:value="ircs">
    <NC:handlerProp RDF:resource="urn:scheme:handler:ircs"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:scheme:handler:ircs"
                   NC:alwaysAsk="true">
    <NC:possibleApplication RDF:resource="urn:handler:web:https://www.mibbit.com/?url=%s"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:mimetype:handler:application/download"
                   NC:alwaysAsk="true" />
  <RDF:Description RDF:about="urn:mimetype:application/csv"
                   NC:value="application/csv"
                   NC:editable="true"
                   NC:fileExtensions="csv"
                   NC:description="Microsoft Excel Comma Separated Values File">
    <NC:handlerProp RDF:resource="urn:mimetype:handler:application/csv"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:schemes">
    <NC:Protocol-Schemes RDF:resource="urn:schemes:root"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:handler:web:https://compose.mail.yahoo.com/?To=%s"
                   NC:prettyName="Yahoo! Mail"
                   NC:uriTemplate="https://compose.mail.yahoo.com/?To=%s" />
  <RDF:Description RDF:about="urn:handler:web:https://www.mibbit.com/?url=%s"
                   NC:prettyName="Mibbit"
                   NC:uriTemplate="https://www.mibbit.com/?url=%s" />
  <RDF:Seq RDF:about="urn:mimetypes:root">
    <RDF:li RDF:resource="urn:mimetype:application/pdf"/>
    <RDF:li RDF:resource="urn:mimetype:application/download"/>
    <RDF:li RDF:resource="urn:mimetype:application/csv"/>
  </RDF:Seq>
  <RDF:Description RDF:about="urn:scheme:handler:irc"
                   NC:alwaysAsk="true">
    <NC:possibleApplication RDF:resource="urn:handler:web:https://www.mibbit.com/?url=%s"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:mimetype:handler:application/csv"
                   NC:alwaysAsk="true" />
  <RDF:Description RDF:about="urn:mimetypes">
    <NC:MIME-types RDF:resource="urn:mimetypes:root"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:mimetype:application/download"
                   NC:value="application/download"
                   NC:editable="true"
                   NC:fileExtensions="csv"
                   NC:description="Microsoft Excel Comma Separated Values File">
    <NC:handlerProp RDF:resource="urn:mimetype:handler:application/download"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:scheme:webcal"
                   NC:value="webcal">
    <NC:handlerProp RDF:resource="urn:scheme:handler:webcal"/>
  </RDF:Description>
  <RDF:Description RDF:about="urn:mimetype:handler:application/pdf"
                   NC:handleInternal="true"
                   NC:alwaysAsk="false" />
  <RDF:Description RDF:about="urn:root"
                   NC:en-US_defaultHandlersVersion="4" />
</RDF:RDF>
Python模块说它是
text/plain

>>> import magic
>>> mime = magic.Magic(mime=True)
>>> mime.from_file("report.csv")
'text/plain'

最后的首选项(为了安全起见,还保留
application/csv
application/download
并添加
application/octet-stream
text/csv
):

Python模块说它是
text/plain

>>> import magic
>>> mime = magic.Magic(mime=True)
>>> mime.from_file("report.csv")
'text/plain'

最后的首选项(为了安全起见,还保留
application/csv
application/download
并添加
application/octet-stream
text/csv
):


application/csv
application/download
通常就是您所需要的。试试:
profile.set_首选项('browser.helperApps.neverAsk.saveToDisk','application/csv,application/download')
。你确定要将
配置文件
传递给
webdriver.Firefox
实例吗?我试过了,但仍然不起作用,是的,它正在webdriver中传递配置文件。driver=webdriver.Firefox(配置文件)这是一个公共站点,您可以共享到它的链接(假设可以注册)?这是一个仅在网络中可用的私有站点。您可以将csv文件(空文件)上传到某个地方供我们测试吗?
application/csv
application/download
通常都是您需要的。试试:
profile.set_首选项('browser.helperApps.neverAsk.saveToDisk','application/csv,application/download')
。你确定要将
配置文件
传递给
webdriver.Firefox
实例吗?我试过了,但仍然不起作用,是的,它正在webdriver中传递配置文件。driver=webdriver.Firefox(配置文件)这是一个公共站点,您可以共享到它的链接(假设可以注册)?这是一个仅在网络中可用的私有站点。您可以将csv文件(空文件)上传到某个地方供我们测试吗?
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/plain,text/csv,application/csv,application/download,application/octet-stream')