Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created March 2, 2020 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lovasoa/1bd16ccf83a49c94e85c0894a0d202cd to your computer and use it in GitHub Desktop.
Save lovasoa/1bd16ccf83a49c94e85c0894a0d202cd to your computer and use it in GitHub Desktop.
Téléchargement en masse d'images HD depuis le site regards.monuments-nationaux.fr
import requests
import re
s = requests.Session()
s.headers.update({'User-Agent': 'M'})
for n in range(91563, 91563+1000):
u = f'https://regards.monuments-nationaux.fr/fr/asset/id/{n}/x/idFeatureFrom/798/thumbIndex/0/mosaicCount/177/ajax/1/format/json'
h = s.get(u).json()['html']
title = re.search('<h1 title="([^"]+)"', h).group(1)
print(title)
url=f'https://regards.monuments-nationaux.fr/fr/asset/highRes/id/{n}/ajax/1/format/json'
r = s.get(url)
u2 = r.json()['html']
r=s.get(u2)
with open(f'images/{title}.jpg', 'wb') as f:
f.write(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment