Created
March 2, 2020 19:48
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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