Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

People here are doing it in Common Lisp and C standard library, meanwhile I’m just sitting here trying to get a curl call to download the data file.


Copy your session token into .token then:

curl "https://adventofcode.com/2024/day/$DAY/input" --header "Cookie: $(cat .token)" > input.txt


You could open the dev console in the browser and copy the curl command off the network tab


I just copy and paste into a local text file, but I bet there’s a tool if you want to do it programmatically already (unless curl’ing is your idea of fun!)


Assuming you already opened it in a web browser, why not right click the page and choose "Save As"?


You can use Firefox: "Copy as cUrl" (https://superuser.com/a/1382425)


The command line tool included with this python library does just what you want once you paste your session token into an environment variable:

https://github.com/wimglenn/advent-of-code-data


I have this script:

  #!/bin/sh
  set -e
  curl "https://adventofcode.com/${YEAR:?}/day/${DAY:?}/input" --cookie "session=$(cat .token)"
then: YEAR=2024 DAY=1 ./aocdata




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: