| Line 290... |
Line 290... |
| 290 |
try:
|
290 |
try:
|
| 291 |
sc = ShopCluesScraper.ShopCluesScraper()
|
291 |
sc = ShopCluesScraper.ShopCluesScraper()
|
| 292 |
url = changeToMobileUrl(url, 5)
|
292 |
url = changeToMobileUrl(url, 5)
|
| 293 |
productInfo = sc.read(url)
|
293 |
productInfo = sc.read(url)
|
| 294 |
except Exception as e:
|
294 |
except Exception as e:
|
| - |
|
295 |
print traceback.print_exc()
|
| 295 |
raise
|
296 |
raise
|
| 296 |
print "LowestPrice ",productInfo['price']
|
297 |
print "LowestPrice ",productInfo['price']
|
| 297 |
if productInfo['price'] > 0 and productInfo['inStock']==1:
|
298 |
if productInfo['price'] > 0 and productInfo['inStock']==1:
|
| 298 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':productInfo['price'],'coupon':productInfo['coupon'],'codAvailable':productInfo['isCod'],'updatedOn':to_java_date(now),'priceUpdatedOn':to_java_date(now),'in_stock':productInfo['inStock']}})
|
299 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':productInfo['price'],'coupon':productInfo['coupon'],'codAvailable':productInfo['isCod'],'updatedOn':to_java_date(now),'priceUpdatedOn':to_java_date(now),'in_stock':productInfo['inStock']}})
|
| 299 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':productInfo['price'] , 'in_stock':productInfo['inStock'],'dealType':data['dealType'], 'rank':data['rank']}})
|
300 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':productInfo['price'] , 'in_stock':productInfo['inStock'],'dealType':data['dealType'], 'rank':data['rank']}})
|
| 300 |
else:
|
301 |
else:
|
| 301 |
lowestPrice = data['available_price']
|
302 |
lowestPrice = data['available_price']
|
| 302 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':0,'priceUpdatedOn':to_java_date(now)}})
|
303 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':0,'priceUpdatedOn':to_java_date(now)}})
|
| 303 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':0,'dealType':data['dealType'],'rank':data['rank']}})
|
304 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':0,'dealType':data['dealType'],'rank':data['rank']}})
|
| 304 |
|
305 |
|
| 305 |
return {'_id':data['_id'],'available_price':lowestPrice,'in_stock':productInfo['inStock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':productInfo['coupon'],'codAvailable':productInfo['isCod']}
|
306 |
return {'_id':data['_id'],'available_price':productInfo['price'],'in_stock':productInfo['inStock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':productInfo['coupon'],'codAvailable':productInfo['isCod']}
|
| 306 |
except Exception as e:
|
307 |
except Exception as e:
|
| 307 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
308 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
| 308 |
print e
|
309 |
print e
|
| 309 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
310 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
| 310 |
|
311 |
|
| Line 373... |
Line 374... |
| 373 |
|
374 |
|
| 374 |
def getLatestPrice(skuBundleId, source_id):
|
375 |
def getLatestPrice(skuBundleId, source_id):
|
| 375 |
temp = []
|
376 |
temp = []
|
| 376 |
itemIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId,'source_id' : source_id}))
|
377 |
itemIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId,'source_id' : source_id}))
|
| 377 |
for item in itemIds:
|
378 |
for item in itemIds:
|
| 378 |
if item['source_id'] ==5 and item['rank'] == 0:
|
- |
|
| 379 |
continue
|
- |
|
| 380 |
item['dealFlag'] = 0
|
379 |
item['dealFlag'] = 0
|
| 381 |
item['dealType'] = 0
|
380 |
item['dealType'] = 0
|
| 382 |
item['dealPoints'] = 0
|
381 |
item['dealPoints'] = 0
|
| 383 |
item['manualDealThresholdPrice'] = None
|
382 |
item['manualDealThresholdPrice'] = None
|
| - |
|
383 |
if item['source_id'] ==5 and item['rank'] == 0:
|
| - |
|
384 |
continue
|
| 384 |
if item['source_id'] ==3:
|
385 |
if item['source_id'] ==3:
|
| 385 |
item['marketPlaceUrl'] = item['marketPlaceUrl']+'?supc='+item.get('identifier')
|
386 |
item['marketPlaceUrl'] = item['marketPlaceUrl']+'?supc='+item.get('identifier')
|
| 386 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':source_id, 'sku':item['_id']}))
|
387 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':source_id, 'sku':item['_id']}))
|
| 387 |
if len(manualDeals) > 0:
|
388 |
if len(manualDeals) > 0:
|
| 388 |
item['dealFlag'] = 1
|
389 |
item['dealFlag'] = 1
|
| Line 478... |
Line 479... |
| 478 |
item['manualDealThresholdPrice'] = manualDeals[0]['dealThresholdPrice']
|
479 |
item['manualDealThresholdPrice'] = manualDeals[0]['dealThresholdPrice']
|
| 479 |
info = returnLatestPrice(item, item['source_id'],False)
|
480 |
info = returnLatestPrice(item, item['source_id'],False)
|
| 480 |
print info
|
481 |
print info
|
| 481 |
|
482 |
|
| 482 |
def main():
|
483 |
def main():
|
| 483 |
print "retuned %s"%(str(getLatestPriceById(23827)))
|
484 |
print "retuned %s"%(str(getLatestPrice(33)))
|
| 484 |
|
485 |
|
| 485 |
if __name__=='__main__':
|
486 |
if __name__=='__main__':
|
| 486 |
main()
|
487 |
main()
|
| 487 |
|
488 |
|