Allow helpers to be imported without cookies
This commit is contained in:
parent
b6c9f3f016
commit
5ab619d420
|
@ -1,14 +1,16 @@
|
||||||
from numpy.typing import ArrayLike
|
from numpy.typing import ArrayLike
|
||||||
import browser_cookie3
|
|
||||||
import datetime
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
today = datetime.date.today()
|
try:
|
||||||
day = today.day
|
import datetime
|
||||||
year = today.year
|
today = datetime.date.today()
|
||||||
def download_input(day: int = day):
|
day = today.day
|
||||||
|
year = today.year
|
||||||
|
|
||||||
|
import browser_cookie3
|
||||||
|
def download_input(day: int = day):
|
||||||
filename = f'input/{day:02}'
|
filename = f'input/{day:02}'
|
||||||
r = requests.get(f"https://adventofcode.com/{year}/day/{day}/input", cookies=browser_cookie3.firefox())
|
r = requests.get(f"https://adventofcode.com/{year}/day/{day}/input", cookies=browser_cookie3.firefox())
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
|
@ -16,6 +18,8 @@ def download_input(day: int = day):
|
||||||
else:
|
else:
|
||||||
with open(filename,'w') as f:
|
with open(filename,'w') as f:
|
||||||
f.write(r.text)
|
f.write(r.text)
|
||||||
|
except ModuleNotFoundError as mod:
|
||||||
|
print(f'{mod.args[0]}, automatic input fetching will not work.')
|
||||||
|
|
||||||
numbers_pattern = re.compile(r'((?:(?<!\d)-)?\d+)')
|
numbers_pattern = re.compile(r'((?:(?<!\d)-)?\d+)')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue