Subversion Repositories SmartDukaan

Rev

Rev 4198 | Rev 5291 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4198 Rev 4203
Line 71... Line 71...
71
                pass
71
                pass
72
        self.phones = phones
72
        self.phones = phones
73
        return phones
73
        return phones
74
    
74
    
75
    def getNextUrl(self):
75
    def getNextUrl(self):
76
        tab_info = self.soup.findAll('div', {'class': 'unit fk-lres-header-text'})[0]('b')
76
        tab_info = self.soup.find('div', {'class': 'unit fk-lres-header-text'})('b')
-
 
77
        
77
        current_max = int(tab_info[0].string.split('-')[1])
78
        current_max = int(tab_info[0].find('span').string)
78
        total = int(tab_info[1].string)
79
        total = int(tab_info[1].string)
79
        
80
        
80
        if len(self.phones) > 0:
81
        if len(self.phones) > 0:
81
            base_url = 'http://www.flipkart.com/mobiles/%s' % ('all/' if self.phones[0]['product_url'].find('/tablets/') == -1 else 'tablet-20278/')
82
            base_url = 'http://www.flipkart.com/mobiles/%s' % ('all/' if self.phones[0]['product_url'].find('/tablets/') == -1 else 'tablet-20278/')
82
            
83
            
Line 103... Line 104...
103
        }
104
        }
104
        return data
105
        return data
105
 
106
 
106
if __name__ == '__main__':
107
if __name__ == '__main__':
107
    s = FlipcartScraper()
108
    s = FlipcartScraper()
108
    data = s.getDataFromProductPage('http://www.flipkart.com/mobiles/micromax/itmd4nf8p5rfhk2y?pid=mobd4nf7rcrckjhn')
109
#    data = s.getDataFromProductPage('http://www.flipkart.com/mobiles/micromax/itmd4nf8p5rfhk2y?pid=mobd4nf7rcrckjhn')
109
    print data
110
#    print data
110
    
111
    
111
#    s.setUrl('http://www.flipkart.com/mobiles/all/27')
-
 
112
#    s.scrape()
-
 
113
#    phones = s.getPhones()
-
 
114
#    for p in phones: print p
-
 
115
#    print s.getNextUrl()
-
 
116
112
    s.setUrl('http://www.flipkart.com/mobiles/all/24')
-
 
113
    s.scrape()
-
 
114
    phones = s.getPhones()
-
 
115
    for p in phones: print p
-
 
116
    print s.getNextUrl()
-
 
117
117
118