使用URL检索文件而不重命名

时间:2019-03-15 17:53:01

标签: python-3.x

URL http://www.example.com/downloads/?latest=rcm&region=GB每天返回一个新文件:例如“ GB_010_2019031212.nc”

我希望python下载文件并使用默认名称保存。 使用此代码,我需要重命名文件。

import requests
url = 'http://www.example.com/downloads/?latest=rcm&region=GB'
myfile = requests.get(url, allow_redirects=True)
open('hello.nc', 'wb').write(myfile.content)

0 个答案:

没有答案