| Line 5... |
Line 5... |
| 5 |
from datetime import datetime, timedelta
|
5 |
from datetime import datetime, timedelta
|
| 6 |
from operator import itemgetter
|
6 |
from operator import itemgetter
|
| 7 |
from dtr.utils.AmazonPriceOnlyScraper import AmazonScraper
|
7 |
from dtr.utils.AmazonPriceOnlyScraper import AmazonScraper
|
| 8 |
from dtr.utils import AmazonDealScraper
|
8 |
from dtr.utils import AmazonDealScraper
|
| 9 |
from dtr.utils import FlipkartScraper,NewFlipkartScraper, ShopCluesScraper, \
|
9 |
from dtr.utils import FlipkartScraper,NewFlipkartScraper, ShopCluesScraper, \
|
| 10 |
PaytmOfferScraper, PaytmScraper
|
10 |
PaytmOfferScraper, PaytmScraper, HomeShop18Scraper
|
| 11 |
from dtr.storage.MemCache import MemCache
|
11 |
from dtr.storage.MemCache import MemCache
|
| 12 |
from functools import partial
|
12 |
from functools import partial
|
| 13 |
import threading
|
13 |
import threading
|
| 14 |
from dtr.utils.utils import getCashBack
|
14 |
from dtr.utils.utils import getCashBack
|
| 15 |
import traceback
|
15 |
import traceback
|
| Line 392... |
Line 392... |
| 392 |
return {'_id':data['_id'],'available_price':available_price,'in_stock':inStock,'source_id':6,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':coupon,'codAvailable':result['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer'],'gross_price':gross_price}
|
392 |
return {'_id':data['_id'],'available_price':available_price,'in_stock':inStock,'source_id':6,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':coupon,'codAvailable':result['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer'],'gross_price':gross_price}
|
| 393 |
except Exception as e:
|
393 |
except Exception as e:
|
| 394 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
394 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
| 395 |
traceback.print_exc()
|
395 |
traceback.print_exc()
|
| 396 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':6,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer'],'gross_price':data.get('gross_price')}
|
396 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':6,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer'],'gross_price':data.get('gross_price')}
|
| - |
|
397 |
|
| - |
|
398 |
elif source_id ==7:
|
| - |
|
399 |
try:
|
| - |
|
400 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| - |
|
401 |
return {}
|
| - |
|
402 |
|
| - |
|
403 |
if data.get('ignorePricing') ==1:
|
| - |
|
404 |
print "Ignored items returning for %d"%(data['_id'])
|
| - |
|
405 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':7,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| - |
|
406 |
|
| - |
|
407 |
try:
|
| - |
|
408 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| - |
|
409 |
print "sku id is already updated",data['_id']
|
| - |
|
410 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':7,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'],'tagline': data['tagline'], 'offer': data['offer']}
|
| - |
|
411 |
|
| - |
|
412 |
except Exception as e:
|
| - |
|
413 |
print "Exception snapdeal"
|
| - |
|
414 |
print e
|
| - |
|
415 |
|
| - |
|
416 |
response = None
|
| - |
|
417 |
|
| - |
|
418 |
try:
|
| - |
|
419 |
scraper = HomeShop18Scraper(True)
|
| - |
|
420 |
response = scraper.read('http://m.homeshop18.com/product.mobi?productId=%s'%(str(data['identifier'])))
|
| - |
|
421 |
except Exception as e:
|
| - |
|
422 |
print e
|
| - |
|
423 |
scraper = HomeShop18Scraper(True)
|
| - |
|
424 |
response = scraper.read('http://m.homeshop18.com/product.mobi?productId=%s'%(str(data['identifier'])))
|
| - |
|
425 |
|
| - |
|
426 |
lowestOfferPrice = 0
|
| - |
|
427 |
inStock = 0
|
| - |
|
428 |
|
| - |
|
429 |
if response is not None:
|
| - |
|
430 |
lowestOfferPrice = response['available_price']
|
| - |
|
431 |
inStock = response['inStock']
|
| - |
|
432 |
|
| - |
|
433 |
print lowestOfferPrice
|
| - |
|
434 |
print inStock
|
| - |
|
435 |
print "*************"
|
| - |
|
436 |
|
| - |
|
437 |
|
| - |
|
438 |
if inStock == 1:
|
| - |
|
439 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':lowestOfferPrice,'updatedOn':to_java_date(now),'priceUpdatedOn':to_java_date(now),'in_stock':inStock,'buyBoxFlag':isBuyBox}}, multi=True)
|
| - |
|
440 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':lowestOfferPrice , 'in_stock':inStock,'codAvailable':data['codAvailable']}}, multi=True)
|
| - |
|
441 |
else:
|
| - |
|
442 |
lowestOfferPrice = data['available_price']
|
| - |
|
443 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock,'priceUpdatedOn':to_java_date(now),'buyBoxFlag':isBuyBox}}, multi=True)
|
| - |
|
444 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':inStock,'codAvailable':data['codAvailable']}}, multi=True)
|
| - |
|
445 |
|
| - |
|
446 |
return {'_id':data['_id'],'available_price':lowestOfferPrice,'in_stock':inStock,'source_id':7,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| - |
|
447 |
except Exception as e:
|
| - |
|
448 |
print traceback.print_exc()
|
| - |
|
449 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
| - |
|
450 |
print e
|
| 397 |
|
451 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':7,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 398 |
|
452 |
|
| 399 |
else:
|
453 |
else:
|
| 400 |
return {}
|
454 |
return {}
|
| 401 |
|
455 |
|
| 402 |
|
456 |
|