Blog Downloader is a little ruby script that can turn your favourite blog into RSS feed. Combined with blog2kindle, you can turn any blog into an ebook to read on your ebook reader, such as Kindle, Apple Books.
Demo: ebook of the Coding Horror blog
Coding Horror page and post object:
# blogs/coding_horror/coding_horror_page.rb
class CodingHorrorPage < Page
def initialize(page_url, page_html)
super(page_url, page_html)
next_page_url_node = page_html.css(".left .read-next-title a").first
previous_page_url_node = page_html.css(".right .read-next-title a").first
@next_page_url = "https://blog.codinghorror.com#{ next_page_url_node.attributes["href"].value }" unless next_page_url_node.nil?
@previous_page_url = "https://blog.codinghorror.com#{ previous_page_url_node.attributes["href"].value }" unless previous_page_url_node.nil?
@post_urls = [@page_url]
end
end
# blogs/coding_horror/coding_horror_posts.rb
class CodingHorrorPost < Post
def initialize(post_url, post_html)
super(post_url, post_html)
@title = post_html.css(".post-title").text
@published_date = post_html.at("meta[property='article:published_time']")['content']
@content = post_html.css(".post-content").children
@author = "Jeff Atwood"
end
end
Config file:
// blogs/coding_horror/config.json
{
"title": "Coding Horror",
"description": "programming and human factors",
"homepage": "https://blog.codinghorror.com",
"direction": "previous",
"remote_base_url": "https://raw.githubusercontent.com/goooooouwa/out/master/coding_horror",
"initial_page": "https://blog.codinghorror.com/building-a-pc-part-ix-downsizing/"
}
ruby ./bin/run.rb page coding_horror
ruby ./bin/run.rb post coding_horror
ruby ./bin/run.rb render coding_horror # generate RSS file in config["our_dir"]
For example, you can publish the RSS feed to a Github repo:
git add ./out/rss.xml
git commit -m "publish blog feeds"
git push origin master # publish the RSS file somewhere online to get an public link
# in blog2kindle
echo "https://raw.githubusercontent.com/goooooouwa/out/master/out/rss.xml" > config/feeds.txt
python3 src/news2kindle.py
Now you will have your favourite blog sent to your Kindle, waiting for you to pick up.