[英]Unpack rar file from URL
I didn't find any answer on how to extract specific files from RAR (not Zip) from URL.我没有找到任何关于如何从 URL 中提取特定文件的答案。
For example, I have this URL whith quite heavy rar: http://cbr.ru/vfs/credit/forms/101-20200401.rar例如,我有这个 URL 很重的rar: http://cbr.ru/vfs/credit/forms/101-20200401.rar
What is the best way to take file from this RAR without downloading it to the disk?从这个 RAR 获取文件而不将其下载到磁盘的最佳方法是什么?
Thanks谢谢
I tried many Python Libraries, but I finally found the solution using rarfile
我尝试了很多 Python 库,但我终于找到了使用
rarfile
的解决方案
1- install rarfile
1-安装
rarfile
2- use the following: 2-使用以下内容:
import urllib
import rarfile
from io import BytesIO
resp = urllib.request.urlopen('http://cbr.ru/vfs/credit/forms/101-20200401.rar')
r = rarfile.RarFile(BytesIO(resp.read()))
r.namelist()
The output will be: output 将是:
['032020N1.DBF', 'NAMES.DBF', '032020B1.DBF']
r.open()
r.open()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.