Skip to content

Instantly share code, notes, and snippets.

@iamsarvagyaa
Created June 16, 2021 12:36
Show Gist options
  • Save iamsarvagyaa/86fc6bc2e3bfdbf3283d8bf87040eb75 to your computer and use it in GitHub Desktop.
Save iamsarvagyaa/86fc6bc2e3bfdbf3283d8bf87040eb75 to your computer and use it in GitHub Desktop.
RSS feed generator for hackthebox blog ...
#!/bin/bash
# @iamsarvagyaa
# RSS feed for hackthebox blog
# Generate {{{
feed="https://www.hackthebox.eu/blog"
mapfile -t articles < <(lynx -dump -listonly "$feed" | grep "/blog/" | awk {'print $NF'} | uniq)
# }}}
# Header {{{
cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>
<![CDATA[Hack The Box Blog]]>
</title>
<description>
<![CDATA[`curl $feed -so - | grep -iPo '(?<=<title>)(.*)(?=</title>)' | recode html..`]]>
</description>
<language>en</language>
<link>$feed</link>
EOF
# }}}
# Body {{{
{
for i in "${articles[@]}";
do
printf " <item>\n"
printf " <title>\n"
printf " <![CDATA[`curl \"$i\" -so - | grep -iPo '(?<=<title>)(.*)(?=</title>)' | recode html..`]]>\n"
printf " </title>\n"
printf " <link>$i</link>\n"
printf " </item>\n"
done
printf " </channel>\n"
printf "</rss>"
}
# }}}
# vim:ft=bash:foldmethod=marker:foldlevel=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment