summaryrefslogtreecommitdiff
path: root/2025/fetch.rs
diff options
context:
space:
mode:
Diffstat (limited to '2025/fetch.rs')
-rw-r--r--2025/fetch.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/2025/fetch.rs b/2025/fetch.rs
new file mode 100644
index 0000000..6c02a8f
--- /dev/null
+++ b/2025/fetch.rs
@@ -0,0 +1,29 @@
+use std::{env, sync::Arc};
+
+use reqwest::{Url, blocking::Client, cookie::Jar};
+
+const YEAR: usize = 2025;
+
+pub fn fetch(lv: usize) -> Vec<String> {
+ let jar = Arc::new(Jar::default());
+ jar.add_cookie_str(
+ &format!(
+ "session={}",
+ env::var("AOC_SESSION").unwrap()
+ ),
+ &Url::parse("https:///adventofcode.com").unwrap(),
+ );
+
+ Client::builder()
+ .cookie_provider(jar)
+ .build()
+ .unwrap()
+ .get(format!("https://adventofcode.com/{YEAR}/day/{lv}"))
+ .send()
+ .unwrap()
+ .text()
+ .unwrap()
+ .lines()
+ .map(|s| s.to_string())
+ .collect()
+}