fix get_input
This commit is contained in:
parent
857a26892e
commit
892759da6c
2 changed files with 3 additions and 5 deletions
|
@ -3,9 +3,11 @@ defmodule AoC do
|
||||||
defp get_request_headers!(), do: [Cookie: "session=#{get_session!()}"]
|
defp get_request_headers!(), do: [Cookie: "session=#{get_session!()}"]
|
||||||
|
|
||||||
def fetch_input!(year, day) do
|
def fetch_input!(year, day) do
|
||||||
|
Application.ensure_all_started(:req)
|
||||||
|
|
||||||
Req.get!(
|
Req.get!(
|
||||||
"https://adventofcode.com/#{year}/day/#{day}/input",
|
"https://adventofcode.com/#{year}/day/#{day}/input",
|
||||||
get_request_headers!()
|
headers: get_request_headers!()
|
||||||
)
|
)
|
||||||
|> Map.get(:body)
|
|> Map.get(:body)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,6 @@ defmodule Mix.Tasks.GetInput do
|
||||||
write_file = &File.write("./input/#{year}_#{day}.txt", &1)
|
write_file = &File.write("./input/#{year}_#{day}.txt", &1)
|
||||||
|
|
||||||
AoC.fetch_input!(year, day)
|
AoC.fetch_input!(year, day)
|
||||||
|> then(fn i ->
|
|
||||||
IO.puts(i)
|
|
||||||
i
|
|
||||||
end)
|
|
||||||
|> write_file.()
|
|> write_file.()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue