Skip to content

Instantly share code, notes, and snippets.

@spookyahell
Created November 20, 2023 20:06
Show Gist options
  • Save spookyahell/00033af0553d7cf1eb4d00a26b1bdc29 to your computer and use it in GitHub Desktop.
Save spookyahell/00033af0553d7cf1eb4d00a26b1bdc29 to your computer and use it in GitHub Desktop.
from os import sep
from os.path import isfile
import requests
bravo_files = [
'BRAVO 1956-01original.pdf',
'BRAVO 1957*1994-01.pdf',
'Starschnitt_081_E.T.zip'
]
def download(file):
fname = 'BRAVO-Archiv{0}{1}'.format(sep, file)
if isfile(fname):
print('{0!r} existiert bereits. -> Kein Grund, zweimal zu laden.'.format(file))
return
print('Fetching {0!r}'.format(file), end = '...', flush = True)
url = 'https://www.bravo-archiv.de/gast/{}'.format(file)
r = requests.get(url)
if r.ok:
print(' OK')
with open(fname, 'wb') as f:
f.write(r.content)
for file in bravo_files:
if '*' in file:
range_start = int(file.split('*')[0].split(' ')[-1])
range_end = int(file.split('*')[-1].split('-')[0])
to_replace = '{0}*{1}'.format(range_start, range_end)
for i in range(range_start, range_end+1):
real_file = file.replace(to_replace, str(i))
download(real_file)
#~ print(real_file)
else:
download(file)
#~ pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment