В вашем скрипте есть несколько ошибок, сначала вам нужно проанализировать файлы в URL, а затем проверить, является ли это gz
файлом или нет
Я попытался сделать пример, используя urllib2
import urllib2
import re
directory = 'https://eogdata.mines.edu/wwwdata/viirs_products/vnf/v30/'
sock = urllib2.urlopen(directory)
sock.close()
found_files = re.findall(r'href="(.*?)"', sock.read()) # here you parse all the files available for download
for file in found_files:
if file.endswith('gz'):
file_location = directory+file # the gz file location
print "downloading %s from %s" % (file, file_location)
file_download = urllib2.urlopen(file_location) # get file from url
with open(file, "wb") as local_file: # open a file with the same name of our gz file
local_file.write(file_download.read()) # write data to our file
file_download.close()