Skip to content

Commit 7d33606

Browse files
committed
Improved scaffolding and scrape
1 parent 635cc24 commit 7d33606

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

.envrc.example

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export AOC_SESSION=""

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea/
2+
.envrc

scrape.sh

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
#!/usr/bin/env bash
22

3-
COOKIE_TOKEN="$1"
4-
YEAR="$2"
5-
DAY="$3"
3+
YEAR="$1"
4+
DAY="$2"
65

76
#create dir
87
mkdir -p "$YEAR/$DAY"
8+
cd "$YEAR/$DAY" || exit
9+
10+
touch output1 output2
11+
12+
GO_TEMPLATE="package main\n\nfunc main() {\n \n}\n"
13+
echo -en "$GO_TEMPLATE" | tee main1.go main2.go >/dev/null
14+
15+
16+
cat >Makefile <<EOF
17+
1:
18+
go run main1.go <input
19+
20+
2:
21+
go run main2.go <input
22+
EOF
923

1024
# download input files
11-
http "https://adventofcode.com/$YEAR/day/$DAY/input" "Cookie:session=$COOKIE_TOKEN;" >"$YEAR/$DAY/input"
25+
http "https://adventofcode.com/$YEAR/day/$DAY/input" "Cookie:session=$AOC_SESSION;" >input
1226

1327
# download assignment
14-
http "https://adventofcode.com/$YEAR/day/$DAY" "Cookie:session=$COOKIE_TOKEN;" | pup 'article.day-desc' >"$YEAR/$DAY/tmp.html"
15-
lynx -dump "$YEAR/$DAY/tmp.html" -width 80 >"$YEAR/$DAY/assignment"
16-
rm -f "$YEAR/$DAY/tmp.html"
28+
http "https://adventofcode.com/$YEAR/day/$DAY" "Cookie:session=$AOC_SESSION;" | pup 'article.day-desc' >tmp.html
29+
lynx -dump tmp.html -width 80 >assignment
30+
rm -f tmp.html

0 commit comments

Comments
 (0)