Titus Stahl

Save Webpages as Ebooks from Firefox

Instead of using proprietary “Read Later” services, I would like to download webpages for later reading and store them on my computer in the epub format.

This can be accomplished easily with pandoc.

Save the following code to an executable file with a .cmd extension:

export fn=`wget --quiet -O - $1 | paste -s -d " " | sed -e 's!.*<head>\(.*\)</head>.*!\1!' | sed -e 's!.*<title>\(.*\)</title>.*!\1!' | sed -e 's/[^A-Za-z0-9._-]//g' | cut -c1-40`
echo $fn
pandoc "https://boilerpipe-web.appspot.com/extract?url=$1&output=htmlFragment" -o /your/directory/$fn.epub

Of course, replace /your/directory with a directory of your choice.

In a second step, add External Applications Button 2 to Firefox. After, restarting Firefox, select your script using the toolbar button. Right click on the toolbar button and add the address barparameter.


Of course, you can also export the articles to PDF, .mobi (Kindle) or any other format that Pandoc supports