-
-
Save DiscoSascha/1bfd5d5a24cc7e2a84eb6ddbf6bf88c7 to your computer and use it in GitHub Desktop.
Perform a full export for your domain
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 argparse | |
| from datetime import datetime | |
| import json | |
| def perform_export(domain, token, updatedSince): | |
| base_url = "https://api.holidu.com" | |
| headers = { | |
| "Accept": "application/json", | |
| "Connection": "keep-alive", | |
| "Authorization": token | |
| } | |
| next_page_path = f"/rest/v6/search/dmo/v1/offers?domain={domain}&locale=de-DE&updatedSince={updatedSince}" | |
| chunk = 1 | |
| start_time = datetime.today().strftime('%Y-%m-%d %H:%M:%S') | |
| while (next_page_path): | |
| print(next_page_path) | |
| response = requests.get(base_url + next_page_path,headers=headers) | |
| response.raise_for_status() | |
| data = response.json() | |
| with open(f'inventory-{start_time}-{chunk}.json', 'w', encoding='utf-8') as f: | |
| json.dump(data, f, indent=4) | |
| chunk += 1 | |
| next_page_path = data['nextPage'] | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser(description = 'Export Holidu inventory') | |
| parser.add_argument('domain', help='Your domain') | |
| parser.add_argument('token', help='The authentication token associated with your domain') | |
| parser.add_argument('updatedSince', help="Filters for apartments who have been updated since the specified point in time. Format: yyyy-MM-dd") | |
| args = parser.parse_args() | |
| domain = args.domain | |
| token = args.token | |
| updatedSince = args.updatedSince | |
| perform_export(domain, token, updatedSince) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment