允许同时下载数千个文件的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第三方库


热门话题
playframework Play Framework 2.5表单对象bean(Java)中的依赖项注入   java从javascript触发小程序按钮   JavaGWT:如何创建我自己的异步方法?   对于JTA事务类型,java JPA更改不会持久化   java如何使用预定义的甲板类制作Black Jack游戏   带有数组的java HashMap find()   从Java中的另一个类接收对象数组的参数?   java IntelliJ错误:Scala 145,错误:scalac:找不到Scala编译器JAR   java Eclipse 404请求的资源不可用   java Chuck没有界限   java阅读行每隔一行跳过一行   java如何访问我的EAR部署信息   Java中的正则表达式,其中执行搜索的文本是动态变化的   java我需要优化BigInteger的toString()方法   java Google Map Api V2,自定义路线标记   java如何在Java8中与LocalDate实现更少的需求和更高的质量   EclipseUML插件生成Java源代码   将数据库列绑定到java jComboBox和JList   java如何将两个图像合并为PDF