Skip to content

Instantly share code, notes, and snippets.

@LupusMichaelis
Created January 14, 2023 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LupusMichaelis/807e660c7c2d47e7511fe5a3536c377b to your computer and use it in GitHub Desktop.
Save LupusMichaelis/807e660c7c2d47e7511fe5a3536c377b to your computer and use it in GitHub Desktop.
Getting article as markdown from dev.to for Cassidoo
#!/bin/bash
# Dependencies:
# apt install curl libxml2-utils python3-html2text
set -euo pipefail
shopt -s lastpipe
# destination repository. For example, the path to your obsidian vault
declare -r dest=~/tmp/cassidoo-gems
declare article
declare title
mkdir -p "$dest"
curl https://dev.to/feed/cassidoo |
xmllint --xpath '//channel/item/link/text()' - |
while read article
do
title=$(printf '%b' "$article" | awk -F/ '{ print $5 }')
curl "$article" |
xmllint --html --xpath '//div[@class="crayons-article__main"]' - |
html2markdown > "$dest/$title.md"
done
@LupusMichaelis
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment