Subversion Repositories SmartDukaan

Rev

Rev 5291 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5291 Rev 6166
Line 20... Line 20...
20
        html = BaseScraper.read(self, self.url)
20
        html = BaseScraper.read(self, self.url)
21
        self.soup = BeautifulSoup(html)
21
        self.soup = BeautifulSoup(html)
22
    
22
    
23
    def getPhones(self):
23
    def getPhones(self):
24
        phone_prices = []
24
        phone_prices = []
-
 
25
        if self.url.find('Cameras') !=-1 :
-
 
26
            ulTagClass = 'srch_result landscape'
-
 
27
        else :
-
 
28
            ulTagClass = 'srch_result portrait'
-
 
29
            
25
        for li in self.soup.findAll('ul', {'class': 'srch_result portrait'})[0]('li'):
30
        for li in self.soup.findAll('ul', {'class': ulTagClass})[0]('li'):
26
            
31
            
27
            name = li.find('span', {'class': 'title'}).contents[1].strip()
32
            name = li.find('span', {'class': 'title'}).contents[1].strip()
28
            try:
33
            try:
29
                price = li.find('div', {'class': 'price'}).find('span', {'class': 'normal'}).string
34
                price = li.find('div', {'class': 'price'}).find('span', {'class': 'normal'}).string
30
            except IndexError:
35
            except IndexError:
Line 60... Line 65...
60
    def getNextUrl(self):
65
    def getNextUrl(self):
61
        b = self.soup.findAll('div', {'class': 'resultsSummary'})[0].findAll('b')
66
        b = self.soup.findAll('div', {'class': 'resultsSummary'})[0].findAll('b')
62
        current_max = int(b[0].string.split('-')[1])
67
        current_max = int(b[0].string.split('-')[1])
63
        total_products = int(b[1].string)
68
        total_products = int(b[1].string)
64
        
69
        
-
 
70
        urlDivider = self.url.find('page=')
-
 
71
        
65
        return 'http://www.infibeam.com/Mobiles/search?page=%d' % (1 + current_max / 20) if current_max < total_products else None
72
        return self.url[:urlDivider] + 'page=%d' % (1 + current_max / 20) if current_max < total_products else None
66
 
73
 
67
    def getDataFromProductPage(self, url):
74
    def getDataFromProductPage(self, url):
68
        html = BaseScraper.read(self, url)
75
        html = BaseScraper.read(self, url)
69
        soup = BeautifulSoup(html)
76
        soup = BeautifulSoup(html)
70
        name = soup.find('div', {'id': 'ib_details'}).find('h1', {'class': "fn"}).find('span', {'class': "item"}).string.strip()
77
        name = soup.find('div', {'id': 'ib_details'}).find('h1', {'class': "fn"}).find('span', {'class': "item"}).string.strip()