Subversion Repositories SmartDukaan

Rev

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

Rev 15210 Rev 15211
Line 23... Line 23...
23
    return soup
23
    return soup
24
 
24
 
25
class AmazonScraper:
25
class AmazonScraper:
26
    def __init__(self,livePricing=None):
26
    def __init__(self,livePricing=None):
27
        self.count_trials = 0
27
        self.count_trials = 0
-
 
28
        self.livePricing = livePricing
28
    
29
    
29
    def read(self, url):
30
    def read(self, url):
30
        response_data = ""
31
        response_data = ""
31
        try:
32
        try:
32
            response_data = fetchResponseUsingProxy(url, self.livePricing)
33
            response_data = fetchResponseUsingProxy(url, livePricing=self.livePricing)
33
        except Exception as e:
34
        except Exception as e:
34
            print 'ERROR: ', e
35
            print 'ERROR: ', e
35
            print 'Retrying'
36
            print 'Retrying'
36
            self.count_trials += 1
37
            self.count_trials += 1
37
            
38
            
Line 68... Line 69...
68
            return dealPrice
69
            return dealPrice
69
        else:
70
        else:
70
            return 0.0
71
            return 0.0
71
 
72
 
72
if __name__ == '__main__':
73
if __name__ == '__main__':
73
    scraper = AmazonScraper()
74
    scraper = AmazonScraper(True)
74
    print scraper.read('http://www.amazon.in/gp/product/B00FXLCLTO')
75
    print scraper.read('http://www.amazon.in/gp/product/B00FXLCLTO')
75
    
76
    
76
77