Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 03-14-2013, 02:13 AM   #1
Steven630
Groupie
Steven630 began at the beginning.
 
Posts: 154
Karma: 10
Join Date: May 2012
Device: Kindle Paperwhite2
More than one page of TOC?

Code:
INDEX = 'http://....'
soup = self.index_to_soup(self.INDEX)
What if I have more than one page of index?
Steven630 is offline   Reply With Quote
Old 03-14-2013, 02:26 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
soup2 = self.index_to_soup(INDEX2)
kovidgoyal is offline   Reply With Quote
Advert
Old 03-14-2013, 08:46 AM   #3
Steven630
Groupie
Steven630 began at the beginning.
 
Posts: 154
Karma: 10
Join Date: May 2012
Device: Kindle Paperwhite2
Quote:
Originally Posted by kovidgoyal View Post
soup2 = self.index_to_soup(INDEX2)
Thank you. Do I need another def parse_index(self)?
Steven630 is offline   Reply With Quote
Old 03-14-2013, 08:50 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
no .
kovidgoyal is offline   Reply With Quote
Old 03-14-2013, 10:01 AM   #5
Steven630
Groupie
Steven630 began at the beginning.
 
Posts: 154
Karma: 10
Join Date: May 2012
Device: Kindle Paperwhite2
Quote:
Originally Posted by kovidgoyal View Post
no .
I'm still a bit confused.

Code:
    def parse_index(self):
        articles = []
        soup = self.index_to_soup(self.INDEX)
        feeds = []
        for section in soup.findAll('div'):
             ...
            for post in section.findAll('li'):
            ...
            if articles:
                feeds.append((section_title, articles))

        return feeds
Do I have to use two "for section in"? (for section in soup.findAll and for section in soup2.findAll?)

UPDATE: I tried two for loops and got all the articles. But articles under the same section name was split.

For example, if in both page 1 and page 2 there's a section called "ABC", then two sections with the name "ABC" appear in TOC.


How can I avoid that?

Last edited by Steven630; 03-14-2013 at 10:22 AM.
Steven630 is offline   Reply With Quote
Advert
Old 03-14-2013, 11:01 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Append the articles from the second section into the first.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Mapping Using toc.ncx lorddon ePub 35 01-16-2018 12:18 PM
Page break for chapters/TOC? neonbible Conversion 2 08-28-2012 09:53 AM
Generated TOC links back to TOC page in the book Caleb666 Sigil 7 08-17-2011 11:58 AM
How to make a TOC page? violent23 Sigil 20 12-07-2010 11:20 AM
Converting a web page to epub with TOC philosopherdog Calibre 5 07-23-2010 07:55 AM


All times are GMT -4. The time now is 11:22 PM.


MobileRead.com is a privately owned, operated and funded community.