AdventOfCode/2019/fetch.py
Adrien Abraham 7e025a3721 Days 1 and 2
2019-12-02 13:59:18 +01:00

18 lines
415 B
Python

import os
import requests
import sys
if len(sys.argv) != 2:
print("Usage: <fetch> day")
sys.exit()
day = sys.argv[1]
URL = "https://adventofcode.com/2019/day/{}/input"
SESSION_ID = os.environ["AOC_SESSION"]
response = requests.get(URL.format(day), cookies={"session": SESSION_ID})
response.raise_for_status()
with open("day{}.txt".format(day), "wt") as output_file:
output_file.write(response.text)