Subversion Repositories SmartDukaan

Rev

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

Rev 15652 Rev 15819
Line 156... Line 156...
156
                
156
                
157
            except Exception as e:
157
            except Exception as e:
158
                print "Exception snapdeal"
158
                print "Exception snapdeal"
159
                print e
159
                print e
160
            
160
            
161
            url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=175"%(data['identifier'])
161
            url="http://www.snapdeal.com/acors/json/v2/gvbps?supc=%s&catUrl=&bn=&catId=175&start=0&count=10000"%(data['identifier'])
162
            req = urllib2.Request(url,headers=headers)
162
            req = urllib2.Request(url,headers=headers)
163
            response = urllib2.urlopen(req)
163
            response = urllib2.urlopen(req)
164
            json_input = response.read()
164
            vendorInfo = json.load(response)
165
            response.close()
165
            response.close()
166
            vendorInfo = json.loads(json_input)
-
 
167
            lowestOfferPrice = 0
166
            lowestOfferPrice = 0
168
            inStock = 0
167
            inStock = 0
169
            buyBoxPrice = 0
168
            buyBoxPrice = 0
170
            isBuyBox = 1
169
            isBuyBox = 1
171
            for vendor in vendorInfo:
170
            try:
172
                buyBoxPrice = float(vendor['sellingPrice'])
171
                buyBoxStock = vendorInfo['primaryVendor']['buyableInventory']
173
                try:
172
                if buyBoxStock >0:
174
                    buyBoxStock = vendor['buyableInventory']
173
                    buyBoxPrice = vendorInfo['primaryVendor']['sellingPrice']
175
                except:
174
            except:
176
                    buyBoxStock = 0
175
                pass
177
                if buyBoxStock > 0 and buyBoxPrice > 0:
-
 
178
                    break
176
            print buyBoxStock
179
                
177
            print buyBoxPrice
180
            sortedVendorsData = sorted(vendorInfo, key=itemgetter('sellingPrice'))
178
            sortedVendorsData = sorted(vendorInfo['vendors'], key=itemgetter('sellingPrice'))
181
            for sortedVendorData in sortedVendorsData:
179
            for sortedVendorData in sortedVendorsData:
182
                lowestOfferPrice = float(sortedVendorData['sellingPrice'])
180
                lowestOfferPrice = float(sortedVendorData['sellingPrice'])
183
                try:
181
                try:
184
                    stock = sortedVendorData['buyableInventory']
182
                    stock = sortedVendorData['buyableInventory']
185
                except:
183
                except:
Line 435... Line 433...
435
            item['manualDealThresholdPrice'] = manualDeals[0]['dealThresholdPrice']
433
            item['manualDealThresholdPrice'] = manualDeals[0]['dealThresholdPrice']
436
        info = returnLatestPrice(item, item['source_id'],False)
434
        info = returnLatestPrice(item, item['source_id'],False)
437
        print info
435
        print info
438
 
436
 
439
def main():
437
def main():
440
    print "retuned %s"%(str(getLatestPrice(1132,1)))
438
    print "retuned %s"%(str(getLatestPriceById(8840)))
441
 
439
 
442
if __name__=='__main__':
440
if __name__=='__main__':
443
    main()
441
    main()
444
    
442