19 lines
551 B
Python
19 lines
551 B
Python
|
import requests
|
||
|
import urllib3
|
||
|
|
||
|
# Session de requêtage HTTP
|
||
|
session = requests.Session()
|
||
|
|
||
|
# Réalise 10 essais de récupération de chaque page, en augmentant
|
||
|
# progressivement le délai entre chaque essai
|
||
|
retry = urllib3.util.Retry(total=10, backoff_factor=0.3)
|
||
|
adapter = requests.adapters.HTTPAdapter(max_retries=retry)
|
||
|
session.mount('http', adapter)
|
||
|
session.mount('https', adapter)
|
||
|
|
||
|
# Identification du robot
|
||
|
session.headers['User-Agent'] = (
|
||
|
'WikimedicaDiseaseSearch/0.1 '
|
||
|
'(https://gitlab.com/matteodelabre/wikimedica-disease-search)'
|
||
|
)
|