manuals/screenshot/mk_screenshot.py

64 lines
2.4 KiB
Python
Raw Normal View History

2022-03-16 13:45:22 +00:00
import subprocess
"""
2022-03-16 16:01:20 +00:00
This script assumes that you have installed wkhtmltopdf (sudo apt install wkhtmltopdf)
2022-03-16 13:45:22 +00:00
"""
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'
2022-03-16 20:39:18 +00:00
COOKIE_VALUE = '3232035445fc07851efd717a8f1d687a'
2022-03-16 13:45:22 +00:00
2022-03-16 16:01:20 +00:00
person_id = 2811
2022-03-16 20:39:18 +00:00
personmineur_id = 2821
2022-03-16 13:45:22 +00:00
household_id = 376
2022-03-16 15:07:28 +00:00
notification_id = 126
parcours_id = 2705
2022-03-16 13:45:22 +00:00
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}',
2022-03-16 16:01:20 +00:00
f'fr/person/{person_id}/document/new',
f'fr/person/{person_id}/document',
2022-03-17 15:11:25 +00:00
# f'fr/parcours/{parcours_id}/document',
2022-03-16 13:45:22 +00:00
f'fr/person/household/{household_id}/summary',
f'fr/person/household/{household_id}/addresses',
2022-03-17 15:11:25 +00:00
# f'fr/person/household/{household_id}/relationship',
2022-03-16 15:07:28 +00:00
'fr/notification/inbox',
f'fr/notification/{notification_id}/show',
2022-03-17 15:11:25 +00:00
# f'fr/notification/create?entityClass=Chill%5CPersonBundle%5CEntity%5CAccompanyingPeriod&entityId={parcours_id}',
2022-03-16 20:39:18 +00:00
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'
2022-03-16 13:45:22 +00:00
]
for u in URLS:
url = BASE_URL + u
2022-03-16 15:07:28 +00:00
filename = 'img/' + u.replace('/', '_').replace('&', '_').replace('?', '_').replace('=', '_') + '.png'
2022-03-16 13:45:22 +00:00
print(f'fetching {url} ...')
2022-03-16 16:01:20 +00:00
subprocess.run(f'wkhtmltoimage -q --javascript-delay 3000 --cookie {COOKIE_KEY} {COOKIE_VALUE} "{url}" {filename}', shell=True, check=True)