View Single Post
Old 03-14-2013, 10:01 AM   #5
Steven630
Groupie
Steven630 began at the beginning.
 
Posts: 180
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