因为服务器上爬取到的40个G的数据采用http,ftp,scp传输到本地效果不太理想。找资料就看到了bypy,利用百度云存储解决这个问题,解决了服务器带宽有限的问题。
pip install bypy ln -s /usr/local/python3/bin/bypy /usr/bin bypy info 访问显示的网址,复制授权码,在命令行下粘贴即可。 bypy upload # 把本地当前目录下的文件上传到app/bypy目录下 bypy downdir /Python从入门到入狱 # 下载 bypy list
python 代码
import os import platform from bypy import ByPy class Adapter: """ bypy 适配器 前提运行 bypy info 登陆成功 """ def __init__(self): self._bp = ByPy() def upload(self,localpath,remotepath,**kwargs): """ 上传 :param localpath: :param remotepath: /videos 实际路径/bypy/videos :param kwargs: :return: """ self._bp.upload(localpath=localpath,remotepath=remotepath,**kwargs) def delete_file(self,path): platf = platform.platform() if "Windows" in platf: os.system("del %s" % path) elif "Linux" in platf: os.system("rm -rf %s" % path) print("!-- delete success %s --!"%path)