允许同时下载数千个文件的python包

blackfeed的Python项目详细描述


黑饲料

BlackFeed is a micro python library that allows you download and upload files concurrently. You can download your files locally but you can also upload them to your cloud without writing them to disk.

所需包装

Installed automatically with pip

  • 请求
  • boto3型

安装

pip install blackfeed

使用

下载文件并上传到AWS S3 要使其工作,必须配置AWS CLI

^{pr2}$

下载状态为

如果不想重新下载同一个文件两次,加载状态可能会很有用。在

fromblackfeed.downloaderimportDownloaderfromblackfeed.adapter.s3importS3Adapterqueue=[...]downloader=Downloader(S3Adapter(bucket='bucketname'),multi=True,stateless=False,state_id='filename')# You can add a callback function if needed# This function will be called after each bulk is processeddefcallback(responses):# response: {#    'destination': destination of the file can be local or can be S3 key,#    'url': URL from where the file was downloaded,#    'httpcode': HTTP code returned by the server,#    'status': True|False,#    'content-type': Mime type of the downloaded resource Example: image/jpeg# }# responses: response[]pass# Your logicdownloader.set_callback(callback)downloader.load_states('filename')# This will load states from "filename.txt"downloader.process(queue)stats=downloader.get_stats()# Statistics 

弹性下载器

Let's you to download/retrieve files from FTP, SFTP and HTTP/S servers easily.

示例

从FTP下载文件

fromblackfeed.elasticdownloaderimportElasticDownloaderuri='ftp://user:password@ftp.server.com/path/to/file.csv'retriever=ElasticDownloader()res=retriever.download(uri,localpath='/tmp/myfile.csv')# localfile is optional# .download() function returns False if there was an error or return the local path of the downloaded file if it was a success.print(res)
/tmp/myfile.csv

从FTP

检索文件的二进制内容
fromblackfeed.elasticdownloaderimportElasticDownloaderuri='ftp://user:password@ftp.server.com/path/to/file.csv'retriever=ElasticDownloader()res=retriever.retrieve(uri)# Return type: io.BytesIO | Falsewithopen('/tmp/myfile.csv','wb')asf:f.write(res.getvalue())

ElasticDownloader可以自动处理FTP、SFTP和HTTP URI。 使用方法download在本地下载文件,并使用retrieve方法获取文件的二进制内容。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JavaFX TableView更新单元格,不更新对象值   在扫描器中使用分隔符的java   java OkHttp 4.9.2,连接无法重用,导致端口耗尽   eclipse中的c JNI:运行Java代码   java是否在出厂的所有硬件设备中都有/mnt/sdcard/Android/data文件夹(或等效文件夹)?   Java,在eclipse中访问资源文件夹中的图像   java为什么Bluemix dashDB操作抛出SqlSyntaxErrorException,SQLCODE=1667?   JavaHtmlUnitWebClient。getPage不处理javascript   Google API认证的java问题   java如何将JSON数组反序列化为Apache beam PCollection<javaObject>   ServerSocket停止接收命令,java/安卓   来自Java类的安卓 Toast消息   java如何自动重新加载应用程序引擎开发服务器?   java是否可以尝试/捕获一些东西来检查是否抛出了异常?   java如何做到这一点当我按下load game时,它不仅会加载信息,还会将您带到游戏中?   Java选项Xmx代表什么?   Java映射,它在插入时打印值   设置“ulimit c unlimited”后,java无法生成系统核心转储