Subversion Repositories SmartDukaan

Rev

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

Rev 4198 Rev 4199
Line 61... Line 61...
61
            except KeyError:
61
            except KeyError:
62
                pass
62
                pass
63
        
63
        
64
        return next_url
64
        return next_url
65
 
65
 
-
 
66
    def getDataFromProductPage(self, url):
-
 
67
        html = BaseScraper.read(self, url)
-
 
68
        soup = BeautifulSoup(html)
-
 
69
        name = soup.find('h1', {'class': 'prod_name'}).string.strip()
-
 
70
        price = removePriceFormatting(soup.find('span',{'class': 'offer_price'}).string.strip())
-
 
71
        
-
 
72
        data = {
-
 
73
            "product_url": str(url),
-
 
74
            "source": "letsbuy",
-
 
75
            "price": price,
-
 
76
            "in_stock": 1,
-
 
77
            "name": name
-
 
78
        }
-
 
79
        return data
-
 
80
 
-
 
81
 
66
if __name__ == '__main__':
82
if __name__ == '__main__':
67
    s = LetsBuyScraper()
83
    s = LetsBuyScraper()
68
    s.setUrl('http://www.letsbuy.com/mobile-phones-mobiles-c-254_88?perpage=192')
-
 
69
    s.scrape()
-
 
70
    phones = s.getPhones()
-
 
71
    print phones
-
 
72
    print s.getNextUrl()
-
 
73
84
    print s.getDataFromProductPage('http://www.letsbuy.com/samsung-galaxy-pop-s5570-p-14143')
-
 
85
    
-
 
86
#    s.setUrl('http://www.letsbuy.com/mobile-phones-mobiles-c-254_88?perpage=192')
-
 
87
#    s.scrape()
-
 
88
#    phones = s.getPhones()
-
 
89
#    print phones
-
 
90
#    print s.getNextUrl()
-
 
91
74
92