From e5f127045b164427b1c4a3a44d789a2958ccc026 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 16 Mar 2022 14:45:22 +0100 Subject: [PATCH] automatic screenshots --- screenshot/.gitignore | 1 + screenshot/img/.gitkeep | 0 screenshot/mk_screenshot.py | 44 +++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 screenshot/.gitignore create mode 100644 screenshot/img/.gitkeep create mode 100644 screenshot/mk_screenshot.py diff --git a/screenshot/.gitignore b/screenshot/.gitignore new file mode 100644 index 0000000..8b6907b --- /dev/null +++ b/screenshot/.gitignore @@ -0,0 +1 @@ +img/*.png \ No newline at end of file diff --git a/screenshot/img/.gitkeep b/screenshot/img/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/screenshot/mk_screenshot.py b/screenshot/mk_screenshot.py new file mode 100644 index 0000000..fe7255a --- /dev/null +++ b/screenshot/mk_screenshot.py @@ -0,0 +1,44 @@ +import subprocess + +""" +This script assumes that you have installed 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 = '57dee6deabd6e0ae75f7a55421fc2427' + +household_id = 376 + +URLS = [ + f'fr/person/household/{household_id}/summary', + f'fr/person/household/{household_id}/addresses', + f'fr/person/household/{household_id}/relationship' +] + +for u in URLS: + url = BASE_URL + u + filename = 'img/' + u.replace('/', '_') + '.png' + print(f'fetching {url} ...') + subprocess.run(f"wkhtmltoimage -q --cookie {COOKIE_KEY} {COOKIE_VALUE} {url} {filename}", shell=True, check=True)