linux 上传文件到百度网盘

一、准备工具:

①、 python-pip:pip 是 Python 包管理工具,该工具提供了对Python 包的查找、下载、安装、卸载的功能。

②、 requests:requests 是 是用python语言基于urllib编写的,采用的是Apache2 Licensed开源协议的HTTP库。

③、 bypy:bypy是百度网盘的python客户

安装命令:

yum install python-pip
pip install requests
pip install bypy

二、授权登录:

[root@localhost ~]# bypy info

显示信息,根据提示,通过浏览器访问链接,如果此时百度网盘账号正在登陆,会出现长串授权码,复制。

Please visit: # 访问下边这个连接,复制授权码
https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&redirect_uri=oob&response_type=code&client_id=H8GUAH2AEF080IAFG

And authorize this app Paste the Authorization Code here within 10 minutes. Press [Enter] when you are done # 提示在下边粘贴授权码

ahuo792usfueghsoghbus3803fs #这是 访问上面网址的百度网盘授权码
Authorizing, please be patient, it may take upto 300 seconds…
Authorizing/refreshing with the OpenShift server …
OpenShift server failed, authorizing/refreshing with the Heroku server …
Heroku server failed, authorizing/refreshing with the Heroku1 server …
Successfully authorized #显示认证成功
Quota: 4.032TB
Used: 1.522TB

三、常用命令:

bypy list 查看目录
bypy mkdir 新建目录
bypy upload 把本地当前目录下的文件同步到百度云盘
bypy downdir 把云盘上的内容同步到本地
bypy list #显示文档
bypy upload filename 上传文档
bypy downdir filename 下载文件(存在问题)
bypy compare 比较本地当前目录和云盘(程序的)根目录
bypy -c 取消令牌文件。一段时间后要重新授权

四、文件上传与同步:

在本地创建一个test文件夹,再在文件夹下创建一个test.txt文本文件。如下:

[root@localhost var]# mkdir test
[root@localhost var]# cd ./test*
[root@localhost test]# vim test.txt

编辑test.txt的内容如下:

上面编辑的test.txt上传到百度云

[root@localhost test]# bypy upload

test.txt 上传到/apps/bypy目录下面的文件和目录。

本文链接地址: linux 上传文件到百度网盘

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注