aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-01 19:04:36 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-01 19:04:36 +0100
commit55c0e82f420c54eb3766bc9830daf966ba6e68f7 (patch)
treea3bb098eea76f66934f0ac8f58b1db2837572534
parent5c6a17174f6675d01bf35999b025c0e99297a844 (diff)
downloadsebastiano.tronto.net-55c0e82f420c54eb3766bc9830daf966ba6e68f7.tar.gz
sebastiano.tronto.net-55c0e82f420c54eb3766bc9830daf966ba6e68f7.zip
Update to blog post
-rw-r--r--src/blog/2025-11-29-aoc-download/aoc-download.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/blog/2025-11-29-aoc-download/aoc-download.md b/src/blog/2025-11-29-aoc-download/aoc-download.md
index 5190aa9..a563955 100644
--- a/src/blog/2025-11-29-aoc-download/aoc-download.md
+++ b/src/blog/2025-11-29-aoc-download/aoc-download.md
@@ -86,3 +86,28 @@ opens up an editor and [Lynx](https://en.wikipedia.org/wiki/Lynx_(web_browser))
86session to set me up to speed, but that is not as interesting. 86session to set me up to speed, but that is not as interesting.
87 87
88Happy coding! 88Happy coding!
89
90### Update 2025-12-01
91
92An interesting addition to my script: now it can also download and save
93the `<code>` blocks and save them each in a separate file. This can
94be useful because these blocks contain example input whose solution is
95provided in the problem's page. The relevant code snippet, based on
96`curl` and `sed`, is this:
97
98```
99url="https://adventofcode.com/$year/day/$daynozero"
100curl "$url" | sed -n '/<pre><code>/,/<\/code><\/pre>/ p' | (\
101 i=1
102 rm -f "code-$i.txt"
103 while read line; do
104 if [ "$line" = "</code></pre>" ]; then
105 i=$((i + 1))
106 rm -f "code-$i.txt"
107 else
108 echo "$line" | sed 's/<.*>//g' >> "code-$i.txt"
109 fi
110 done
111)
112```
113

Generated with cgit - Back to sebastiano.tronto.net