python - Webdriver:在保存到文件夹之前更改文件名
问题描述
当我使用webdriver浏览网站时,它会自动将文件下载到我的文件夹中,但是文件名为“Bike.gz”,是否可以将其名称更改为“{当前时间}.txt”,然后再保存到我的文件夹?例如,如“2019-03-07-11-46.txt”。
代码:
options = webdriver.ChromeOptions()
options.add_experimental_option("prefs", {
"download.default_directory": r"\\xxx.xx.xxx.xx\bike_test",
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": True
})
driver_main = webdriver.Chrome(chrome_options=options)
driver_main.get("http://data.xxxx/xxxx")
另外,“\xxx.xx.xxx.xx\bike_test”是我的 NAS 路径,如果我在 AWS 上运行它,如何下载文件并将其直接保存到我的 NAS 文件夹bike_test?还是我必须先将其保存在我的 AWS 文件夹中,然后再对其进行转换?
解决方案
推荐阅读
- web-audio-api - 创建一个具有 4 个通道的 audioWorkletNode?
- javascript - 找不到模块“日期格式”
- symfony - 使用 Symfony 4.1.3 声明服务时如何从自动装配中排除域?
- python - python:在本地安装matplotlib
- ios - 如何为地理位置创建边界框
- python - 如何使用 python 检索命令行上显示的输出?
- javascript - bootstrap.js 是否包含事件处理逻辑?如果是这样,浏览器怎么知道?
- visual-studio - 创建更新 MSBUILD 进程以在构建目标之前运行程序的 NuGet 包
- java - Hibernate - 通过 Id 查询进行简单提取不起作用,但按对象查询可以
- hyperledger-fabric - Hyperledger Fabric 无法更新块且没有错误响应