百度云盘的python-api,官方API
方法 | 描述 |
---|---|
安装 | 安装方式 |
list | 查看该目录下有哪些文件 |
meta | 可以查看某个文件的具体信息 |
upload | 上传单个文件 |
download | 下载单个文件 |
upload_dir | 上传文件夹 |
download_dir | 下载文件夹 |
获取百度cookies中的BDUSS值,注意保密
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive(bduss="XXXXXXXXXXXXXXXXXXXXXXXX",save=True)
第一次使用后,会将BDUSS存入'~/.secret/.bduss'(save=True时)
如果允许保存到本地,则下次调用不用传入dbuss,即
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive()
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive()
for path in client.list("/drive/example/api"):
print(path['server_filename'])
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive()
print(client.meta("/drive/example/api/test.txt"))
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive()
client.upload('test.txt', '/drive/example/api/test.txt', overwrite=False)
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive()
client.download( '/drive/example/api/test.txt','test2.txt', overwrite=False)
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive()
client.upload_dir('logs', '/drive/example/api/')
from fundrive.baidu.drive import BaiDuDrive
client = BaiDuDrive()
client.download_dir('/drive/example/api/', 'logs')