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 4199
Line 60... Line 60...
60
        current_max = int(b[0].string.split('-')[1])
60
        current_max = int(b[0].string.split('-')[1])
61
        total_products = int(b[1].string)
61
        total_products = int(b[1].string)
62
        
62
        
63
        return 'http://www.infibeam.com/Mobiles/search?page=%d' % (1 + current_max / 20) if current_max < total_products else None
63
        return 'http://www.infibeam.com/Mobiles/search?page=%d' % (1 + current_max / 20) if current_max < total_products else None
64
 
64
 
-
 
65
    def getDataFromProductPage(self, url):
-
 
66
        html = BaseScraper.read(self, url)
-
 
67
        soup = BeautifulSoup(html)
-
 
68
        name = soup.find('div', {'id': 'ib_details'}).find('h1', {'class': "fn"}).find('span', {'class': "item"}).string.strip()
-
 
69
        price = removePriceFormatting(soup.find('div',{'id': 'priceDiv'}).find('span', {'class': 'infiPrice amount price'}).string)
-
 
70
        in_stock = soup.find('div', {'id': 'colors'}).find('span', {'class':"status"}).string.strip()
-
 
71
        
-
 
72
        data = {
-
 
73
            "product_url": str(url), 
-
 
74
            "source": "infibeam", 
-
 
75
            "price": price, 
-
 
76
            "in_stock": 1 if in_stock == 'In Stock.' else 0, 
-
 
77
            "name": name
-
 
78
        }
-
 
79
        return data
-
 
80
 
65
if __name__ == '__main__':
81
if __name__ == '__main__':
66
    s = InfibeamScraper()
82
    s = InfibeamScraper()
67
    s.setUrl('http://www.infibeam.com/Mobiles/search?page=17')
-
 
68
    s.scrape()
-
 
69
    products = s.getPhones()
-
 
70
    print products
-
 
71
83
    print s.getDataFromProductPage('http://www.infibeam.com/Mobiles/i-HTC-EVO-3D-Android-Smartphone/P-E-M-HTC-EVO-3D.html?id=Black')
-
 
84
#    s.setUrl('http://www.infibeam.com/Mobiles/search?page=17')
-
 
85
#    s.scrape()
-
 
86
#    products = s.getPhones()
-
 
87
#    print products
-
 
88
72
89