aboutsummaryrefslogtreecommitdiff
path: root/rss.py
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2018-01-18 13:43:19 +0800
committerclarkzjw <[email protected]>2018-01-18 13:43:19 +0800
commite12cf1463848faa973d7c2ec174892655d131c22 (patch)
tree74e0313a2029dfcdac57c9eaf431223305533c1c /rss.py
parent50def653ece79940e270f741942c99b5a223cc15 (diff)
downloadblog.jinwei.me-e12cf1463848faa973d7c2ec174892655d131c22.tar.gz
+ fix
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)