From 866436c73338c2d0caa0cb35dff4949048943fee Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Thu, 11 Jan 2018 20:54:06 +0800 Subject: + add rss --- rss.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'rss.py') 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): return env.get_template(template_path).render(context) -def _remove_attrs(soup): - for tag in soup.findAll(True): - tag.attrs = None - return soup - - def main(): filenames = glob.glob("./_build/html/_posts/*/*/*.html") @@ -41,11 +35,12 @@ def main(): for p in filenames: soup = BeautifulSoup(open(p), "html5lib") - body = soup.find_all("div", class_="body") + body = soup.find_all("div", class_="body")[0].text + posts.append({ "title": soup.title.string, - "body": body[0].text, - "date_rss": "", + "body": body, + "date_rss": body[body.find("Publish Date:")+13:body.find("Publish Date:")+23], "permalink": "/".join(p.split("/")[3:]) }) @@ -53,7 +48,7 @@ def main(): "site": { "name": "Hello World", "url": "https://blog.jinwei.me", - "tagline": "Freedom is my birthright and I shall have it." + "tagline": "Freedom is my birth right and I shall have it." }, "posts": posts } -- cgit v1.2.3