Answers.Body: <p>I prefer Calibre solution. Debian Calibre package come with <code>ebook-convert</code> utility.</p>
  
  <p>Grab HTML files from site by:</p>
  
  <pre><code>$ wget -r -np -nc -k -c http://.../.../..
  </code></pre>
  
  <p>Locate your main HTML file (usually <code>book.html</code> or <code>index.html</code>) and convert to MOBI:</p>
  
  <pre><code>$ cd dir-with-index
  $ ebook-convert index.html book.mobi
  $ ebook-convert index.html book.fb2
  $ ebook-convert index.html book.epub
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-30T13:31:12.803Z
Answers.Text: Works fantastic with epub. Just the answer I was looking for. Thanks
Answers.UserDisplayName: mythicalcoder
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-27T06:52:24.807Z
Answers.Text: On Mac need set up the Path to use this command 
  `echo 'export PATH=/Applications/calibre.app/Contents/MacOS/:$PATH' >> ~/.profile` and `source ~/.profile`
Answers.UserDisplayName: Xin Meng
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-07T14:24:41.717Z
Answers.Text: Is there a way to use `ebook-convert` recursively? It gets the index.html in the main directory but not in subdirectories. I have tried giving it a list of paths, but that doesn't seem to work.
Answers.UserDisplayName: zadrozny
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-27T22:14:10.137Z
Answers.LastActivityDate: 2015-11-27T22:14:10.137Z
Answers.UserDisplayName: gavenkoa
Answers.Body: <p>I had the exact same problem for a long time. You can produce good results with Calibre, but I found the process was a bit involved. </p>
  
  <p>Instead I created a way to do this much more easily. It's a browser extension called EpubPress (<a href="https://epub.press" rel="noreferrer">https://epub.press</a>). </p>
  
  <p>All you do is:</p>
  
  <ol>
  <li>Open the webpages you want to save in different tabs.</li>
  <li>Open EpubPress</li>
  <li>Select all the pages you want in your ebook</li>
  <li>Download</li>
  </ol>
  
  <p>The content from the pages gets extracted and stitched together into an ebook.</p>
  
  <p>Hope that helps!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-12T12:03:44.233Z
Answers.Text: This is exactly what I was looking for.  Thank you for creating this!
Answers.UserDisplayName: Arthur
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-08T14:17:04.677Z
Answers.Text: This is a genius project, exactly what I was missing without knowing it. Now I can get rid of the accumulation of tabs I want to read "someday" without cluttering the Kindle with a lot of short articles like before. Works perfectly and you can even select `.mobi` in the settings. No need for kindlegen or Calibre anymore.
Answers.UserDisplayName: Suzana
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-11T04:20:11.713Z
Answers.LastActivityDate: 2016-06-03T04:54:41.760Z
Answers.LastEditDate: 2016-06-03T04:54:41.760Z
Answers.UserDisplayName: Harold
Answers.Body: <p>One thought is the Sigil e-book-building software. It's available for Linux and I believe it would do what you need although there is some manual manipulation involved.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-12-20T11:10:09.440Z
Answers.Text: Actually, it's available for all current operating systems... ;)
Answers.UserDisplayName: e-sushi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-12-18T22:51:20.570Z
Answers.LastActivityDate: 2013-12-18T22:51:20.570Z
Answers.UserDisplayName: Padawan Learner
Answers.Body: <p>I went nuts figuring this out. Developed mile long Xpath strings and what not.  Then it turned out to be ridiculously simple. I am ignoring op systems in this answer...</p>
  
  <p>(a) for the conversion to epub use Calibre. It imports as a zip file. No need to make a zip file beforehand. Then you convert the zip to ebook in Calibre.</p>
  
  <p>(b) spider the web site: Cyotek WebCopy or HTTrack Website Copier will do just fine. This will create a browsable mirror of the web site on your local device.
  (if the web has an index page or site map listing the pages, your job is easy.)</p>
  
  <p>(c) Take the site map or index or whatever page that does the best listing of what's in the web. Copy it, naming it "Table Of Contents". Edit it and change title to Table Of Contents. Change (or make one if there is none) the first header to h1>Table Of Contents. If needed, make your additions to the links in this file. ( I am assuming this file is the parent to all links. If other files refer back to this file, see if you can just use the original parent file without changing its file name as the "Table Of Contents" file. Just change its html title and header and see what happens.)</p>
  
  <p>(d) to set up calibre, go to "preferences" ==> Common Options. Untick everything in the "Heuristic processing" and "Structure detection" pages. On the "Table Of Contents" page tick "Force use of auto generated Table Of Contents and Do not add detected chapters. ToC Level thingies should be blank also. That is it.</p>
  
  <p>(d) Click "add book" button in Calibre and select your "Table Of Contents" file. Calibre will create the book in zip format. Then select your book and click "convert books". You have your ebook!</p>
  
  <p>(e) if you want to make changes in your ToC after making the epub, it is easier with Sigil. Load your book in Sigil. go to tools==>Table Of Contents==> Edit Table Of Contents. Table Of Contents editor probably has what it takes to make the changes.</p>
  
  <hr>
  
  <p>the tutorial site is very well organized. so here is another way to go about it.</p>
  
  <p>You need to download the web contents with an app like httrack.
  You can download httrack from
  <a href="https://apps.ubuntu.com/cat/applications/precise/webhttrack/" rel="nofollow noreferrer">https://apps.ubuntu.com/cat/applications/precise/webhttrack/</a></p>
  
  <p>The best way to go may be to use Calibre to create an epub,
  and then convert it to mobi again with calibre
  You can download Calibre for Ubuntu from
  <a href="https://calibre-ebook.com/download_linux" rel="nofollow noreferrer">https://calibre-ebook.com/download_linux</a>
  or
  <a href="https://apps.ubuntu.com/cat/applications/lucid/calibre/" rel="nofollow noreferrer">https://apps.ubuntu.com/cat/applications/lucid/calibre/</a></p>
  
  <p>The tutorial @ <a href="https://docs.python.org/3/tutorial/index.html" rel="nofollow noreferrer">https://docs.python.org/3/tutorial/index.html</a> is already well organized so it is doable.</p>
  
  <p>Here is one way of going about it...</p>
  
  <p>after you download it set up Calibre
  click preferences -> common options</p>
  
  <p>select structure detection
  in Detect Chapters at xpath expression blank
  paste:     //<em>[((name()='h1' or name()='h2' or name()='h3') and re:test(., '\s</em>((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))', 'i')) or @class = 'chapter']</p>
  
  <p>select Table of Contents
  check Force use of auto-generatyed table of Contents
  for ToC level 1 select h1 with magic wand
  for ToC level 2 select h2 with magic wand
  for ToC level 3 select h2 with magic wand</p>
  
  <p>That's it for Calibre setup</p>
  
  <p>Now you can click the add books button
  go to your download folder 
  go all the way in to the tutorial folder
  and select index.html
  calibre will create a book in zip format</p>
  
  <p>select the book and click convert books button</p>
  
  <p>you will end up with an epub with an acceptable ToC
  to clean up the ToC
  you can click edit book -> select table of contents and edit
  then you can convert to mobi</p>
  
  <p>sorry about the bold. I could not get rid of it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-18T17:25:11.907Z
Answers.LastActivityDate: 2017-09-29T04:31:41.640Z
Answers.LastEditDate: 2017-09-29T04:31:41.640Z
Answers.UserDisplayName: guest
Answers.Body: <p>Another option is <a href="https://dotepub.com" rel="nofollow noreferrer">https://dotepub.com</a>, which does not require the installation of any additional programs, works across all platforms and is free. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-13T17:05:40.463Z
Answers.LastActivityDate: 2017-10-13T17:05:40.463Z
Answers.UserDisplayName: user26732
Answers.Body: <p>Of course you can. The easiest method is </p>
  
  <ol>
  <li>save the whole site into a folder (e.g. mirror it with some command line tool like <code>wget</code> - it is available on Windows too - or <a href="http://www.httrack.com/">Httrack</a>)</li>
  <li>zip the folder</li>
  <li>send the zip to your device via Amazon e-mail solution.</li>
  </ol>
  
  <p><a href="http://www.amazon.com/gp/sendtokindle">Here's the official Amazon page documenting this feature.</a></p>
  
  <p>If it's not what you want, you can use <a href="http://calibre-ebook.com">Calibre</a> to convert HTML to various ebook formats, <a href="http://manual.calibre-ebook.com/conversion.html">here is the official documentation</a>.</p>
  
  <p>And even more, you can download the official <a href="http://www.amazon.com/gp/feature.html?docId=1000765211">Kindlegen Linux CLI tool from Amazon</a> and hand tailor the downloaded HTML with your favourite editor then convert it.</p>
  
  <p>(And <a href="http://docs.python.org/3/download.html">you can download the official Python docs in EPUB format</a> which Amazon happily convert for you (the mailing method), and every other conversion option I had mentioned above will work with the EPUB too.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-16T08:59:37.330Z
Answers.Text: Amazon does not covert EPUB books when you email them with "convert" in the subject line. You have to send a MOBI file. So the best way to go with an EPUB is to convert it to MOBI using Calibre and then send it to your Kindle account via email.
Answers.UserDisplayName: Ramon Suarez
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-16T20:40:46.097Z
Answers.Text: It was working in the good old days. Anyhow, according to this: http://the-digital-reader.com/2016/04/27/how-to-send-epub-to-your-kindle-by-email/ (and I just tried it), you can still rename the `file.epub` to `file.zip` then send the zip file which get converted.
Answers.UserDisplayName: Zsolt Botykai
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-28T23:26:31.263Z
Answers.Text: It works.. but you cannot put more than 25 html docs in each zip
Answers.UserDisplayName: Bhikkhu Subhuti
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-08T13:39:45.090Z
Answers.Text: Renaming `epub` to `zip` is not possible anymore, either. Just tested it :-(
Answers.UserDisplayName: Suzana
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-12-18T21:43:51.283Z
Answers.Text: I've just tried sending the email, and got an email with error message: `A problem with your document(s) sent to <MY_EMAIL_HERE>`. :(
Answers.UserDisplayName: elias
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-12-18T20:43:08.423Z
Answers.LastActivityDate: 2014-05-10T19:08:02.070Z
Answers.LastEditDate: 2014-05-10T19:08:02.070Z
Answers.UserDisplayName: Zsolt Botykai
Body: <p>I'd like to create a <code>.mobi</code> file from a website like the <a href="http://docs.python.org/3/tutorial/index.html">Python Tutorial</a>, to read on my Kindle.</p>
  
  <p>Is it possible to do it on Ubuntu?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-12-18T20:38:56.213Z
Comments.Text: You mean the whole site, right? Not just a single page.
Comments.UserDisplayName: svick
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-12-18T20:45:58.933Z
Comments.Text: @svick right, it would need to follow the links on that table of contents at least.
Comments.UserDisplayName: elias
Tags: <mobi><html><conversion>
Title: How can I convert an HTML site into an ebook?
UserDisplayName: elias
ThreadText: # How can I convert an HTML site into an ebook?
  
  (Asked by: username_0 on 2013-12-18)
  
  I'd like to create a `.mobi` file from a website like the [Python Tutorial](http://docs.python.org/3/tutorial/index.html), to read on my Kindle.
  
  Is it possible to do it on Ubuntu?
  
  **Tags:** mobi, html, conversion
  
  > **Comments:**
  > **username_1**: You mean the whole site, right? Not just a single page.  
  > **username_0**: @username_1 right, it would need to follow the links on that table of contents at least.  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_13 on 2013-12-18. Score: 51 | Accepted answer
  
  Of course you can. The easiest method is
  
  1. save the whole site into a folder (e.g. mirror it with some command line tool like `wget` - it is available on Windows too - or [Httrack](http://www.httrack.com/))
  2. zip the folder
  3. send the zip to your device via Amazon e-mail solution.
  
  [Here's the official Amazon page documenting this feature.](http://www.amazon.com/gp/sendtokindle)
  
  If it's not what you want, you can use [Calibre](http://calibre-ebook.com) to convert HTML to various ebook formats, [here is the official documentation](http://manual.calibre-ebook.com/conversion.html).
  
  And even more, you can download the official [Kindlegen Linux CLI tool from Amazon](http://www.amazon.com/gp/feature.html?docId=1000765211) and hand tailor the downloaded HTML with your favourite editor then convert it.
  
  (And [you can download the official Python docs in EPUB format](http://docs.python.org/3/download.html) which Amazon happily convert for you (the mailing method), and every other conversion option I had mentioned above will work with the EPUB too.)
  
  > **Comments:**
  > **username_0**: I've just tried sending the email, and got an email with error message: `A problem with your document(s) sent to <MY_EMAIL_HERE>`. :(  
  > **username_14**: Amazon does not covert EPUB books when you email them with "convert" in the subject line. You have to send a MOBI file. So the best way to go with an EPUB is to convert it to MOBI using Calibre and then send it to your Kindle account via email.  
  > **username_13**: It was working in the good old days. Anyhow, according to this: http://the-digital-reader.com/2016/04/27/how-to-send-epub-to-your-kindle-by-email/ (and I just tried it), you can still rename the `file.epub` to `file.zip` then send the zip file which get converted.  
  > **username_15**: It works.. but you cannot put more than 25 html docs in each zip  
  > **username_8**: Renaming `epub` to `zip` is not possible anymore, either. Just tested it :-(  
  
  ---
  
  ### Answer by username_2 on 2015-11-27. Score: 33
  
  I prefer Calibre solution. Debian Calibre package come with `ebook-convert` utility.
  
  Grab HTML files from site by:
  
  ```
  $ wget -r -np -nc -k -c http://.../.../..
  
  ```
  
  Locate your main HTML file (usually `book.html` or `index.html`) and convert to MOBI:
  
  ```
  $ cd dir-with-index
  $ ebook-convert index.html book.mobi
  $ ebook-convert index.html book.fb2
  $ ebook-convert index.html book.epub
  
  ```
  
  > **Comments:**
  > **username_3**: Works fantastic with epub. Just the answer I was looking for. Thanks  
  > **username_4**: On Mac need set up the Path to use this command  `echo 'export PATH=/Applications/calibre.app/Contents/MacOS/:$PATH' >> ~/.profile` and `source ~/.profile`  
  > **username_5**: Is there a way to use `ebook-convert` recursively? It gets the index.html in the main directory but not in subdirectories. I have tried giving it a list of paths, but that doesn't seem to work.  
  
  ---
  
  ### Answer by username_6 on 2016-05-11. Score: 18
  
  I had the exact same problem for a long time. You can produce good results with Calibre, but I found the process was a bit involved.
  
  Instead I created a way to do this much more easily. It's a browser extension called EpubPress (<https://epub.press>).
  
  All you do is:
  
  1. Open the webpages you want to save in different tabs.
  2. Open EpubPress
  3. Select all the pages you want in your ebook
  4. Download
  
  The content from the pages gets extracted and stitched together into an ebook.
  
  Hope that helps!
  
  > **Comments:**
  > **username_7**: This is exactly what I was looking for.  Thank you for creating this!  
  > **username_8**: This is a genius project, exactly what I was missing without knowing it. Now I can get rid of the accumulation of tabs I want to read "someday" without cluttering the Kindle with a lot of short articles like before. Works perfectly and you can even select `.mobi` in the settings. No need for kindlegen or Calibre anymore.  
  
  ---
  
  ### Answer by username_9 on 2013-12-18. Score: 5
  
  One thought is the Sigil e-book-building software. It's available for Linux and I believe it would do what you need although there is some manual manipulation involved.
  
  > **Comments:**
  > **username_10**: Actually, it's available for all current operating systems... ;)  
  
  ---
  
  ### Answer by username_11 on 2017-09-18. Score: 4
  
  I went nuts figuring this out. Developed mile long Xpath strings and what not. Then it turned out to be ridiculously simple. I am ignoring op systems in this answer...
  
  (a) for the conversion to epub use Calibre. It imports as a zip file. No need to make a zip file beforehand. Then you convert the zip to ebook in Calibre.
  
  (b) spider the web site: Cyotek WebCopy or HTTrack Website Copier will do just fine. This will create a browsable mirror of the web site on your local device.
  (if the web has an index page or site map listing the pages, your job is easy.)
  
  (c) Take the site map or index or whatever page that does the best listing of what's in the web. Copy it, naming it "Table Of Contents". Edit it and change title to Table Of Contents. Change (or make one if there is none) the first header to h1>Table Of Contents. If needed, make your additions to the links in this file. ( I am assuming this file is the parent to all links. If other files refer back to this file, see if you can just use the original parent file without changing its file name as the "Table Of Contents" file. Just change its html title and header and see what happens.)
  
  (d) to set up calibre, go to "preferences" ==> Common Options. Untick everything in the "Heuristic processing" and "Structure detection" pages. On the "Table Of Contents" page tick "Force use of auto generated Table Of Contents and Do not add detected chapters. ToC Level thingies should be blank also. That is it.
  
  (d) Click "add book" button in Calibre and select your "Table Of Contents" file. Calibre will create the book in zip format. Then select your book and click "convert books". You have your ebook!
  
  (e) if you want to make changes in your ToC after making the epub, it is easier with Sigil. Load your book in Sigil. go to tools==>Table Of Contents==> Edit Table Of Contents. Table Of Contents editor probably has what it takes to make the changes.
  
  ---
  
  the tutorial site is very well organized. so here is another way to go about it.
  
  You need to download the web contents with an app like httrack.
  You can download httrack from
  <https://apps.ubuntu.com/cat/applications/precise/webhttrack/>
  
  The best way to go may be to use Calibre to create an epub,
  and then convert it to mobi again with calibre
  You can download Calibre for Ubuntu from
  <https://calibre-ebook.com/download_linux>
  or
  <https://apps.ubuntu.com/cat/applications/lucid/calibre/>
  
  The tutorial @ <https://docs.python.org/3/tutorial/index.html> is already well organized so it is doable.
  
  Here is one way of going about it...
  
  after you download it set up Calibre
  click preferences -> common options
  
  select structure detection
  in Detect Chapters at xpath expression blank
  paste: //*[((name()='h1' or name()='h2' or name()='h3') and re:test(., '\s*((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))', 'i')) or @class = 'chapter']
  
  select Table of Contents
  check Force use of auto-generatyed table of Contents
  for ToC level 1 select h1 with magic wand
  for ToC level 2 select h2 with magic wand
  for ToC level 3 select h2 with magic wand
  
  That's it for Calibre setup
  
  Now you can click the add books button
  go to your download folder
  go all the way in to the tutorial folder
  and select index.html
  calibre will create a book in zip format
  
  select the book and click convert books button
  
  you will end up with an epub with an acceptable ToC
  to clean up the ToC
  you can click edit book -> select table of contents and edit
  then you can convert to mobi
  
  sorry about the bold. I could not get rid of it.
  
  
  ---
  
  ### Answer by username_12 on 2017-10-13. Score: 1
  
  Another option is <https://dotepub.com>, which does not require the installation of any additional programs, works across all platforms and is free.
  
  
  ---
  
  