Subversion Repositories SmartDukaan

Rev

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

Rev 15270 Rev 15820
Line 99... Line 99...
99
            print "sku id is already updated",data['_id'] 
99
            print "sku id is already updated",data['_id'] 
100
            return
100
            return
101
    except:
101
    except:
102
        pass
102
        pass
103
    
103
    
104
    url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=175"%(data['identifier'].strip())
104
    url="http://www.snapdeal.com/acors/json/v2/gvbps?supc=%s&catUrl=&bn=&catId=175&start=0&count=10000"%(data['identifier'].strip(()))
105
    print url
105
    print url
106
    time.sleep(1)
106
    time.sleep(1)
107
    lowestOfferPrice = 0
107
    lowestOfferPrice = 0
108
    instock = 0
108
    instock = 0
109
    buyBoxPrice = 0
109
    buyBoxPrice = 0
110
    isBuyBox = 1
110
    isBuyBox = 1
111
    stock = 0
111
    stock = 0
112
    req = urllib2.Request(url,headers=headers)
112
    req = urllib2.Request(url,headers=headers)
113
    response = urllib2.urlopen(req)
113
    response = urllib2.urlopen(req)
-
 
114
    try:
114
    json_input = response.read()
115
        vendorInfo = json.load(response)
115
    response.close()
116
    except:
116
    if len(json_input) > 0:
117
        return
117
        vendorInfo = json.loads(json_input)
118
    finally:
118
        for vendor in vendorInfo:
119
        response.close()
119
            buyBoxPrice = float(vendor['sellingPrice'])
-
 
-
 
120
 
120
            try:
121
    try:
121
                buyBoxStock = vendor['buyableInventory']
122
        buyBoxStock = vendorInfo['primaryVendor']['buyableInventory']
122
            except:
-
 
123
                buyBoxStock = 0
123
        if buyBoxStock >0:
124
            if buyBoxStock > 0 and buyBoxPrice > 0:
124
            buyBoxPrice = vendorInfo['primaryVendor']['sellingPrice']
-
 
125
    except:
125
                break
126
        pass
126
            
127
        
127
        sortedVendorsData = sorted(vendorInfo, key=itemgetter('sellingPrice'))
128
    sortedVendorsData = sorted(vendorInfo['vendors'], key=itemgetter('sellingPrice'))
128
        for sortedVendorData in sortedVendorsData:
129
    for sortedVendorData in sortedVendorsData:
129
            lowestOfferPrice = float(sortedVendorData['sellingPrice'])
130
        lowestOfferPrice = float(sortedVendorData['sellingPrice'])
130
            try:
131
        try:
131
                stock = sortedVendorData['buyableInventory']
132
            stock = sortedVendorData['buyableInventory']
132
            except:
133
        except:
133
                pass
134
            pass
134
            if stock > 0 and lowestOfferPrice > 0:
135
        if stock > 0 and lowestOfferPrice > 0:
135
                instock = 1
136
            instock = 1
136
                break
137
            break
137
        if buyBoxPrice != lowestOfferPrice:
138
    if buyBoxPrice != lowestOfferPrice:
138
            isBuyBox = 0
139
        isBuyBox = 0
139
 
140
 
140
    print lowestOfferPrice
141
    print lowestOfferPrice
141
    print instock
142
    print instock
142
    print "Lowest Offer Price for id %d is %d , stock is %d and stock count is %d" %(data['_id'],lowestOfferPrice,instock,stock)
143
    print "Lowest Offer Price for id %d is %d , stock is %d and stock count is %d" %(data['_id'],lowestOfferPrice,instock,stock)
143
    print "*************"
144
    print "*************"