import subprocess """ This script assumes that you have installed wkhtmltopdf (sudo apt install wkhtmltopdf) """ BASE_URL = 'https://quinquina.champs-libres.be/' """ To get a valid cookie key/value, copy as curl a request in your browser: curl 'https://quinquina.champs-libres.be/_wdt/708fb5' \ -H 'Connection: keep-alive' \ -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"' \ -H 'X-Requested-With: XMLHttpRequest' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36' \ -H 'sec-ch-ua-platform: "Linux"' \ -H 'Accept: */*' \ -H 'Sec-Fetch-Site: same-origin' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Referer: https://quinquina.champs-libres.be/fr/person/household/376/relationship' \ -H 'Accept-Language: en-US,en;q=0.9' \ -H 'Cookie: PHPSESSID=57dee6deabd6e0ae75f7a55421fc2427' \ --compressed """ COOKIE_KEY = 'PHPSESSID' COOKIE_VALUE = '3232035445fc07851efd717a8f1d687a' person_id = 2811 personmineur_id = 2821 household_id = 376 notification_id = 126 parcours_id = 2705 URLS = [ 'fr/person/new', f'fr/person/{person_id}/general', f'fr/person/{person_id}/residential-address/list', f'fr/person/{person_id}/resources/list', f'fr/activity/?accompanying_period_id={parcours_id}', f'fr/person/{person_id}/document/new', f'fr/person/{person_id}/document', # f'fr/parcours/{parcours_id}/document', f'fr/person/household/{household_id}/summary', f'fr/person/household/{household_id}/addresses', # f'fr/person/household/{household_id}/relationship', 'fr/notification/inbox', f'fr/notification/{notification_id}/show', # f'fr/notification/create?entityClass=Chill%5CPersonBundle%5CEntity%5CAccompanyingPeriod&entityId={parcours_id}', f'fr/vendee/vendeeperson/{person_id}/infosociopro/view', f'fr/vendee/vendeeperson/{person_id}/infomedicale/view', f'fr/vendee/vendeepersonmineur/{personmineur_id}/infofamille/view', f'fr/vendee/vendeepersonmineur/{personmineur_id}/scolarite/view' ] for u in URLS: url = BASE_URL + u filename = 'img/' + u.replace('/', '_').replace('&', '_').replace('?', '_').replace('=', '_') + '.png' print(f'fetching {url} ...') subprocess.run(f'wkhtmltoimage -q --javascript-delay 3000 --cookie {COOKIE_KEY} {COOKIE_VALUE} "{url}" {filename}', shell=True, check=True)