我想从一个名为hdrihaven.com的网站下载多个.hdr文件。 我对python的了解不是很好,但以下是我迄今为止尝试过的内容:
import requests
url = 'https://hdrihaven.com/files/hdris/'
resolution = '4k'
file = 'pump_station' #would need to be every file
url_2k = url + file + '_' + resolution + '.hdr'
print(url_2k)
r = requests.get(url_2k, allow_redirects=True)
open(file + resolution + '.hdr', 'wb').write(r.content)
理想情况下file
只需在目录中的每个文件上循环
提前感谢您的回答
编辑
我在github上找到了一个脚本,它可以满足我的需要:https://github.com/Alzy/hdrihaven_dl。我在这里编辑它以满足我的需要:https://github.com/ktkk/hdrihaven-downloader。它使用的技术是,按照评论中的建议,循环浏览所有可用文件的列表
我发现请求模块和urllib比从Chrome上下载本机的速度要慢得多。如果有人对我如何加快这些有想法,请让我知道
有两种方法可以做到这一点:
您可以使用
URL
获取所有文件,并通过循环进行迭代以分别下载它们。当然,这只有在存在这样一个URL
的情况下才有效您可以将单个
URL
传递给可以并行/批量下载它们的函数例如:
此代码段取自此处Download multiple files (Parallel/bulk download)。请继续阅读,了解更多有关如何做到这一点的信息
相关问题 更多 >
编程相关推荐