diff options
Diffstat (limited to 'fetch-data')
| -rwxr-xr-x | fetch-data | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fetch-data b/fetch-data new file mode 100755 index 000000000..b6fc8c661 --- /dev/null +++ b/fetch-data | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | import os | ||
| 3 | import sys | ||
| 4 | import requests | ||
| 5 | |||
| 6 | for slug in sys.argv[1:]: | ||
| 7 | id = open(os.path.join("events", slug, "id"), "r").read() | ||
| 8 | data_path = os.path.join("events", slug, "data.json") | ||
| 9 | if os.path.exists(data_path): | ||
| 10 | continue | ||
| 11 | data_url = f"https://portugalrunning.com/wp-json/wp/v2/ajde_events/{id}" | ||
| 12 | response = requests.get(data_url) | ||
| 13 | response.raise_for_status() | ||
| 14 | with open(data_path, "w") as f: | ||
| 15 | f.write(response.text) | ||
| 16 | |||
