Subversion Repositories SmartDukaan

Rev

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

Rev 14188 Rev 14189
Line 7... Line 7...
7
from dtr.utils.AmazonPriceOnlyScraper import AmazonScraper
7
from dtr.utils.AmazonPriceOnlyScraper import AmazonScraper
8
from dtr.utils import FlipkartScraper,NewFlipkartScraper
8
from dtr.utils import FlipkartScraper,NewFlipkartScraper
9
 
9
 
10
con = None
10
con = None
11
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3}
11
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3}
12
scraperFk = FlipkartScraper.FlipkartScraper()
-
 
13
scraperAmazon = AmazonScraper()
-
 
14
scraperProductPage = NewFlipkartScraper.FlipkartProductPageScraper()
-
 
15
 
12
 
16
headers = { 
13
headers = { 
17
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
14
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
18
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
15
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
19
            'Accept-Language' : 'en-US,en;q=0.8',                     
16
            'Accept-Language' : 'en-US,en;q=0.8',                     
Line 46... Line 43...
46
                pass
43
                pass
47
            
44
            
48
            
45
            
49
            url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(data['identifier'])
46
            url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(data['identifier'])
50
            lowestPrice = 0.0
47
            lowestPrice = 0.0
-
 
48
            scraperAmazon = AmazonScraper()
51
            lowestPrice = scraperAmazon.read(url)
49
            lowestPrice = scraperAmazon.read(url)
52
            print "LowestPrice ",lowestPrice
50
            print "LowestPrice ",lowestPrice
53
            inStock = 0
51
            inStock = 0
54
            if lowestPrice > 0:
52
            if lowestPrice > 0:
55
                inStock = 1
53
                inStock = 1
Line 133... Line 131...
133
            except:
131
            except:
134
                pass
132
                pass
135
            
133
            
136
            lowestSp = 0
134
            lowestSp = 0
137
            inStock = 0
135
            inStock = 0
-
 
136
            scraperProductPage = NewFlipkartScraper.FlipkartProductPageScraper()
138
            try:
137
            try:
139
                if data['marketPlaceUrl']!="" or data['marketPlaceUrl'] !="http://www.flipkart.com/ps/%s"%(data['identifier']):
138
                if data['marketPlaceUrl']!="" or data['marketPlaceUrl'] !="http://www.flipkart.com/ps/%s"%(data['identifier']):
140
                    result = scraperProductPage.read(data['marketPlaceUrl'])
139
                    result = scraperProductPage.read(data['marketPlaceUrl'])
141
                    print result
140
                    print result
142
                    if result.get('lowestSp')!=0:
141
                    if result.get('lowestSp')!=0:
Line 144... Line 143...
144
                        inStock = result.get('inStock')
143
                        inStock = result.get('inStock')
145
            except:
144
            except:
146
                print "Unable to scrape product page ",data['identifier']
145
                print "Unable to scrape product page ",data['identifier']
147
            if lowestSp ==0:
146
            if lowestSp ==0:
148
                url = "http://www.flipkart.com/ps/%s"%(data['identifier'])
147
                url = "http://www.flipkart.com/ps/%s"%(data['identifier'])
-
 
148
                scraperFk = FlipkartScraper.FlipkartScraper()
149
                vendorsData = scraperFk.read(url)
149
                vendorsData = scraperFk.read(url)
150
                sortedVendorsData = []
150
                sortedVendorsData = []
151
                sortedVendorsData = sorted(vendorsData, key=itemgetter('sellingPrice'))
151
                sortedVendorsData = sorted(vendorsData, key=itemgetter('sellingPrice'))
152
                print "data",sortedVendorsData
152
                print "data",sortedVendorsData
153
                for vData in sortedVendorsData:
153
                for vData in sortedVendorsData: