aboutsummaryrefslogtreecommitdiff
path: root/rss.py
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2018-01-11 20:54:06 +0800
committerclarkzjw <[email protected]>2018-01-11 20:54:06 +0800
commit866436c73338c2d0caa0cb35dff4949048943fee (patch)
tree7c8a37f83f755c7badd982d1bb2f950c40556393 /rss.py
parent78760ab08d1d2ca51004934ac8ff690be38fd7ce (diff)
downloadblog.jinwei.me-866436c73338c2d0caa0cb35dff4949048943fee.tar.gz
+ add rss
Diffstat (limited to 'rss.py')
-rw-r--r--rss.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/rss.py b/rss.py
index faa004c..fdf4b53 100644
--- a/rss.py
+++ b/rss.py
@@ -26,12 +26,6 @@ def render_template(cwd, template_path, context):
26 return env.get_template(template_path).render(context) 26 return env.get_template(template_path).render(context)
27 27
28 28
29def _remove_attrs(soup):
30 for tag in soup.findAll(True):
31 tag.attrs = None
32 return soup
33
34
35def main(): 29def main():
36 30
37 filenames = glob.glob("./_build/html/_posts/*/*/*.html") 31 filenames = glob.glob("./_build/html/_posts/*/*/*.html")
@@ -41,11 +35,12 @@ def main():
41 35
42 for p in filenames: 36 for p in filenames:
43 soup = BeautifulSoup(open(p), "html5lib") 37 soup = BeautifulSoup(open(p), "html5lib")
44 body = soup.find_all("div", class_="body") 38 body = soup.find_all("div", class_="body")[0].text
39
45 posts.append({ 40 posts.append({
46 "title": soup.title.string, 41 "title": soup.title.string,
47 "body": body[0].text, 42 "body": body,
48 "date_rss": "", 43 "date_rss": body[body.find("Publish Date:")+13:body.find("Publish Date:")+23],
49 "permalink": "/".join(p.split("/")[3:]) 44 "permalink": "/".join(p.split("/")[3:])
50 }) 45 })
51 46
@@ -53,7 +48,7 @@ def main():
53 "site": { 48 "site": {
54 "name": "Hello World", 49 "name": "Hello World",
55 "url": "https://blog.jinwei.me", 50 "url": "https://blog.jinwei.me",
56 "tagline": "Freedom is my birthright and I shall have it." 51 "tagline": "Freedom is my birth right and I shall have it."
57 }, 52 },
58 "posts": posts 53 "posts": posts
59 } 54 }
Powered by cgit v1.2.3 (git 2.41.0)