aboutsummaryrefslogtreecommitdiff
path: root/rss.py
diff options
context:
space:
mode:
Diffstat (limited to 'rss.py')
-rw-r--r--rss.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/rss.py b/rss.py
index 928bf34..af9f0ca 100644
--- a/rss.py
+++ b/rss.py
@@ -1,7 +1,7 @@
1import glob
1import os 2import os
2import jinja2
3 3
4import glob 4import jinja2
5from bs4 import BeautifulSoup 5from bs4 import BeautifulSoup
6 6
7 7
@@ -31,16 +31,18 @@ def main():
31 filenames = glob.glob("./_build/html/_posts/*/*/*.html") 31 filenames = glob.glob("./_build/html/_posts/*/*/*.html")
32 posts = [] 32 posts = []
33 33
34 for p in filenames: 34 for file in filenames:
35 soup = BeautifulSoup(open(p), "html5lib") 35 soup = BeautifulSoup(open(file), "html5lib")
36 body = soup.find_all("div", class_="body")[0].text 36 body = soup.find_all("div", class_="body")[0].text
37 37
38 posts.append({ 38 posts.append({
39 "title": soup.title.string, 39 "title": soup.title.string,
40 "body": body, 40 "body": body,
41 "date_rss": body[body.find("Publish Date:")+13:body.find("Publish Date:")+23], 41 "date_rss": body[body.find("Publish Date:")+13:body.find("Publish Date:")+23],
42 "permalink": "/".join(p.split("/")[3:]) 42 "permalink": "/".join(file.split("/")[3:])
43 }) 43 })
44 with open(file, "w") as file:
45 file.write(str(BeautifulSoup(str(soup).replace("\n", "").replace("\r", ""), "html5lib").prettify()))
44 46
45 context = { 47 context = {
46 "site": { 48 "site": {
Powered by cgit v1.2.3 (git 2.41.0)