Linux实现上传文件到百度网盘 |
您所在的位置:网站首页 › 如何将文件上传至百度云盘 › 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 bypypython-pip 安装失败【提示:没有可用软件包 python-pip。】 解决方法如下: 先安装epel-release,这个包包含了 EPEL 源的 gpg 密钥和软件源信息,该软件包会自动配置yum的软件仓库 [root@localhost yum.repos.d]#yum -y install epel-release 二、授权登录:执行 bypy info,显示下边信息,根据提示,通过浏览器访问下边灰色的https链接,如果此时百度网盘账号正在登陆,会出现长串授权码,复制。 [root@ineedle ~]# bypy info Please visit: # 访问下边这个连接,复制授权码 https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&redirect_uri=oob&response_type=code&client_id=q8WE4EpCsau1oS0MplgMKNBn And authorize this app Paste the Authorization Code here within 10 minutes. Press [Enter] when you are done # 提示在下边粘贴授权码 a0bd012145abd7caa508618d985f8cfb #这是 访问上面网址的百度网盘授权码 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: 2.011TB Used: 1.192TB在本地创建一个KormeeSData文件夹,再在文件夹下创建一个test.txt文本文件。如下: [root@localhost var]# mkdir KormeeSData [root@localhost var]# cd ./Korm* [root@localhost KormeeSData]# vim test.txt编辑test.txt的内容如下:
注意事项: 由于百度PCS API权限限制,程序只能存取百度云端/apps/bypy目录下面的文件和目录。 其他操作: 把云盘上的内容同步到本地。命令如下: [root@localhost KormeeSData]#bypy downdir 比较本地当前目录和云盘根目录,看是否一致,来判断是否同步成功: [root@localhost KormeeSData]#bypy compare |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |