Subversion Repositories SmartDukaan

Rev

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

Rev 17181 Rev 17262
Line 244... Line 244...
244
            inStock = 0
244
            inStock = 0
245
            buyBoxPrice = 0
245
            buyBoxPrice = 0
246
            isBuyBox = 0
246
            isBuyBox = 0
247
            scraperProductPage = NewFlipkartScraper.FlipkartProductPageScraper()
247
            scraperProductPage = NewFlipkartScraper.FlipkartProductPageScraper()
248
            try:
248
            try:
249
                if data['marketPlaceUrl']!="" or data['marketPlaceUrl'] !="http://www.flipkart.com/ps/%s"%(data['identifier']):
-
 
250
                    result = scraperProductPage.read(data['marketPlaceUrl'])
249
                result = scraperProductPage.read(data['identifier'])
251
                    print result
250
                print result
252
                    if result.get('lowestSp')!=0:
251
                if result.get('lowestSp')!=0:
253
                        lowestSp = result.get('lowestSp')
252
                    lowestSp = result.get('lowestSp')
254
                        inStock = result.get('inStock')
253
                    inStock = result.get('inStock')
255
                        buyBoxPrice = result.get('buyBoxPrice')
254
                    buyBoxPrice = result.get('buyBoxPrice')
256
            except:
255
            except:
257
                print "Unable to scrape product page ",data['identifier']
256
                print "Unable to scrape product page ",data['identifier']
258
            if lowestSp ==0:
-
 
259
                url = "http://www.flipkart.com/ps/%s"%(data['identifier'])
-
 
260
                scraperFk = FlipkartScraper.FlipkartScraper()
-
 
261
                vendorsData, buyBoxInfo = (scraperFk.read(url))
-
 
262
                sortedVendorsData = []
-
 
263
                sortedVendorsData = sorted(vendorsData, key=itemgetter('sellingPrice'))
-
 
264
                print "data",sortedVendorsData
-
 
265
                for vData in sortedVendorsData:
-
 
266
                    lowestSp = vData['sellingPrice']
-
 
267
                    break
-
 
268
                if lowestSp > 0:
-
 
269
                    inStock = 1
-
 
270
                try:
-
 
271
                    buyBoxPrice = buyBoxInfo[0].get('sellingPrice')
-
 
272
                except:
-
 
273
                    buyBoxPrice = None
-
 
274
            print lowestSp
257
            print lowestSp
275
            print inStock
258
            print inStock
276
            if buyBoxPrice is not None and buyBoxPrice == lowestSp:
259
            if buyBoxPrice is not None and buyBoxPrice == lowestSp:
277
                isBuyBox = 1
260
                isBuyBox = 1
278
            if lowestSp > 0:
261
            if lowestSp > 0:
Line 683... Line 666...
683
        info = returnLatestPrice(item, item['source_id'],False)
666
        info = returnLatestPrice(item, item['source_id'],False)
684
        print info
667
        print info
685
 
668
 
686
def main():
669
def main():
687
    print datetime.now()
670
    print datetime.now()
688
    print "retuned %s"%(str(getLatestPrice(1428,7)))
671
    print "retuned %s"%(str(getLatestPriceById(7)))
689
    print datetime.now()
672
    print datetime.now()
690
if __name__=='__main__':
673
if __name__=='__main__':
691
    main()
674
    main()
692
    
675