-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_rss.sh
executable file
·43 lines (37 loc) · 1.32 KB
/
get_rss.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Assuming blog.html is in the current directory
HTML_FILE="blog.html"
OUTPUT_XML="tmp_feed.xml"
# Start the RSS feed
cat << EOF > "$OUTPUT_XML"
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Amosnimos's Blog Feed</title>
<link>https://amosnimos.com</link>
<description>Recent articles from Amosnimos's blog</description>
<language>en-us</language>
<pubDate>$(date -R)</pubDate>
<lastBuildDate>$(date -R)</lastBuildDate>
<generator>ChatGPT RSS Generator</generator>
EOF
# Extract links from blog.html and create RSS items
grep -oE '<a class="btn-v" href="[^"]+' "$HTML_FILE" | while read -r line; do
link=$(echo "$line" | sed 's/<a class="btn-v" href="//')
title=$(basename "$link" | sed 's/-/ /g')
pubDate=$(echo "$line" | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}')
description="Description for $title" # Replace with actual descriptions if available
cat << EOF >> "$OUTPUT_XML"
<item>
<title>$title</title>
<link>https://amosnimos.com/$link</link>
<pubDate>$(date -d "$pubDate" -R)</pubDate>
<guid>https://amosnimos.com/$link</guid>
<description>$description</description>
</item>
EOF
done
# End the RSS feed
echo " </channel>" >> "$OUTPUT_XML"
echo "</rss>" >> "$OUTPUT_XML"
echo "RSS feed generated: $OUTPUT_XML"