diff options
Diffstat (limited to 'rss.py')
-rw-r--r-- | rss.py | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -1,7 +1,7 @@ | |||
1 | import glob | ||
1 | import os | 2 | import os |
2 | import jinja2 | ||
3 | 3 | ||
4 | import glob | 4 | import jinja2 |
5 | from bs4 import BeautifulSoup | 5 | from 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": { |