1、参考网址:GitHub - ly0/baidupcsapi: 百度网盘api
树莓派实现上传文件到百度云_Camlin_Z的博客-CSDN博客
2、编写一个脚本实现长传图片,命名为:pic_upload.py
import progressbar
from baidupcsapi import PCS
class ProgressBar():
def __init__(self):
self.first_call = True
def __call__(self, *args, **kwargs):
if self.first_call:
self.widgets = [progressbar.Percentage(), ' ', progressbar.Bar(marker=progressbar.RotatingMarker('>')),
' ', progressbar.ETA()]
self.pbar = progressbar.ProgressBar(widgets=self.widgets, maxval=kwargs['size']).start()
self.first_call = False
if kwargs['size'] <= kwargs['progress']:
self.pbar.finish()
else:
self.pbar.update(kwargs['progress'])
pcs = PCS('账户名','账户密码')
test_file = open('example_04.jpg','rb').read()
ret = pcs.upload('/',test_file,'example_04.jpg',callback=ProgressBar())
3、在虚拟环境pi_py3环境下运行:
python3 pic_upload.py
要输入图片的验证码,还要接收邮箱的数字验证码,有些麻烦