Browse Source

first import

Bachir Soussi Chiadmi 6 years ago
commit
14640ec431
2 changed files with 54 additions and 0 deletions
  1. 49 0
      import.py
  2. 5 0
      index.html

+ 49 - 0
import.py

@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+
+import feedparser
+from bs4 import BeautifulSoup
+
+def main():
+   # url du flux rss
+   tpsreac_feed_url = "https://tempsdereaction.wordpress.com/feed/"
+
+   # on aspire le flux rss avec feedparser
+   tpsreac_feeds = feedparser.parse(tpsreac_feed_url)
+
+   # base template du fichier html
+   base = "<html><head></head><body></body></html>"
+   # create dom for html file base
+   base_dom = BeautifulSoup(base, 'html.parser')
+
+   # page base template
+   page_base = "<section class='page'></section>"
+
+   # boucle sur les entrées racine du flux
+   for key in tpsreac_feeds:
+      print(key)
+
+   # on boucle sur les entrées du flux rss
+   for entrie in tpsreac_feeds['entries']:
+      print('- - - - -',entrie['title'])
+      # just display entrie keys
+      for key in entrie:
+         print(key)
+         #     entries.extend( feed[ "items" ] )
+
+      # create page dom
+      p_dom = BeautifulSoup(page_base, 'html.parser')
+      # add content in page dom
+      p_dom.section.append(entrie['summary'])
+
+      # add newly created page dom to html dom
+      base_dom.body.append(p_dom)
+
+   # create main html file from filled base html dom
+   with open("index.html", 'w') as fp:
+      fp.write(base_dom.prettify(formatter=None))
+
+
+if __name__ == "__main__":
+   main()

File diff suppressed because it is too large
+ 5 - 0
index.html


Some files were not shown because too many files changed in this diff