User:Albert Jongstra/duplicators/td feedbook
TECHNICAL ASSIGNMENT 1
Feed-Book
Create a script that automatically generates a (simple) eBook based on an online (changing) source, such as an RSS feed.
Run your script (unchanged) on two different times (days?) to produce two different results (and save the results separately).
bash book.sh
python feed.py > feedbook/OEBPS/content.html
cd feedbook
zip -0Xq feedbook.epub mimetype
zip -Xr9Dq feedbook.epub *
lucidor feedbook.epub
python feed.py
#Looking inside the RSS Feed
import feedparser
# Calling the information from the website and giving it the name "newwork"
newwork = feedparser.parse("http://3voor12.vpro.nl/feeds/lokaal/friesland")
import pprint
#pprint.pprint(newwork)
#print(newwork.entries[4]["title"])
print """
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>feedbook</title>
<link type="text/css" rel="stylesheet" media="all" href="stylesheet.css" />
</head>
<body>"""
for e in newwork.entries:
print"<h1>"
print e["title"].replace("&", "&").encode("utf-8")
print"</h1>"
print"<p>"
print e["summary"].replace("&", "&").encode("utf-8")
print"</p>"
print
print"""
</body>
</html>"""