Last active
July 15, 2024 06:17
-
-
Save matlinuxer2/f2d2485726c08ee5b1473667ff5889c6 to your computer and use it in GitHub Desktop.
Convert COSCUP 2024 session list into a markdown table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
dbg=":" | |
if [ "$DEBUG" = "1" ] || [ "$DEBUT" = "true" ] || [ "$DEBUT" = "yes" ]; then | |
dbg="" | |
fi | |
function to_result() { | |
cat >>$tmpd/result.md | |
} | |
tmpd=$(mktemp -d) | |
( | |
( | |
printf " | Speakers | Subject | Notes |\n" | |
printf " | ---- | ---- | ---- |\n" | |
) | to_result | |
curl -skL https://coscup.org/2024/zh-TW/session | sed -e "s/\(<div class=\"cell-content\"\)/\\n\1/g" | grep schedule-item | while read -r line; do | |
$dbg echo "====================" | |
echo "$line" | sed -e "s/></>\n</g" | grep -e "\(href\|name\|period\|title\|\"speaker\"\)" >$tmpd/out1 | |
$dbg cat $tmpd/out1 | |
url=$(cat $tmpd/out1 | grep -e "schedule-item" | sed -e "s/.*href=\"\(.*\)\" class.*/\1/g") | |
url="https://coscup.org$url" | |
$dbg echo $url | |
room=$(cat $tmpd/out1 | grep -e "\"name\"" | sed -e "s/.*class=\"name\">\(.*\)<.*/\1/g") | |
$dbg echo $room | |
when=$(cat $tmpd/out1 | grep -e "period" | sed -e "s/.*period\">\(.*\)<.*/\1/g") | |
$dbg echo $when | |
speakers=$(cat $tmpd/out1 | grep -e "speaker" | sed -e "s/.*speaker\">\(.*\)<.*/\1/g" | paste -s | sed -e "s/\t/<br\/>/g") | |
speakers=${speakers:- ----} | |
$dbg echo $speakers | |
title=$(cat $tmpd/out1 | grep -e "title" | sed -e "s/.*title\">\(.*\)<.*/\1/g") | |
$dbg echo $title | |
echo "| $speakers | [$title]($url) | $when , $room |" | to_result | |
done | |
cat $tmpd/result.md | |
) | |
rm -r $tmpd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment