ReqAOC Usage Guide
Mix.install([
{:req_aoc, github: "mcrumm/req_aoc", ref: "9f1371b"}
])
Input
This guide provides a starting point for downloading Advent of Code data in Livebook. The first step is to configure AOC_SESSION
in your app secrets, which requires Livebook v0.7+. Run the following block and click ‘Add Secret’ when prompted:
input =
System.fetch_env!("LB_AOC_SESSION")
|> ReqAOC.fetch!({2022, 01}, max_retries: 0)
How to get your session cookie
Puzzle inputs differ by user. For this reason, you can’t get your data with an unauthenticated request. Here’s how to get your session cookie for ReqAOC to use:
- Log in on Advent of Code via any available provider.
- Open your browser’s developer console (e.g. right click –> Inspect) and navigate to the Network tab.
- GET any input page, for example https://adventofcode.com/2022/day/1/input, and search in the request headers.
-
It’s a long hex string. You want the part that comes after
Cookie: session=
. Save that to a system environment variable or a Livebook app secret calledAOC_SESSION
.