| Line 6... |
Line 6... |
| 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 FlipkartScraper,NewFlipkartScraper
|
8 |
from dtr.utils import FlipkartScraper,NewFlipkartScraper
|
| 9 |
|
9 |
|
| 10 |
con = None
|
10 |
con = None
|
| 11 |
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3}
|
11 |
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
|
| 12 |
|
12 |
|
| 13 |
headers = {
|
13 |
headers = {
|
| 14 |
'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
14 |
'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
| 15 |
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
15 |
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
| 16 |
'Accept-Language' : 'en-US,en;q=0.8',
|
16 |
'Accept-Language' : 'en-US,en;q=0.8',
|
| Line 83... |
Line 83... |
| 83 |
url = "http://109.74.200.220:8080/mobileapi/dtr-pricing?id=%s"%(data['identifier'])
|
83 |
url = "http://109.74.200.220:8080/mobileapi/dtr-pricing?id=%s"%(data['identifier'])
|
| 84 |
lowestPrice = 0.0
|
84 |
lowestPrice = 0.0
|
| 85 |
instock = 0
|
85 |
instock = 0
|
| 86 |
req = urllib2.Request(url,headers=headers)
|
86 |
req = urllib2.Request(url,headers=headers)
|
| 87 |
response = urllib2.urlopen(req)
|
87 |
response = urllib2.urlopen(req)
|
| - |
|
88 |
print response.read()
|
| 88 |
response.close()
|
89 |
response.close()
|
| 89 |
json_input = response.read()
|
90 |
json_input = response.read()
|
| 90 |
priceInfo = json.loads(json_input)
|
91 |
priceInfo = json.loads(json_input)
|
| 91 |
lowestPrice = priceInfo['response']['sellingPrice']
|
92 |
lowestPrice = priceInfo['response']['sellingPrice']
|
| - |
|
93 |
print "*****"
|
| - |
|
94 |
print lowestPrice
|
| - |
|
95 |
print instock
|
| 92 |
if lowestPrice > 0:
|
96 |
if lowestPrice > 0:
|
| 93 |
instock = 1
|
97 |
instock = 1
|
| 94 |
if instock == 1:
|
98 |
if instock == 1:
|
| 95 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':lowestPrice,'updatedOn':to_java_date(now),'priceUpdatedOn':to_java_date(now),'in_stock':inStock}}, multi=True)
|
99 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':lowestPrice,'updatedOn':to_java_date(now),'priceUpdatedOn':to_java_date(now),'in_stock':inStock}}, multi=True)
|
| 96 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':lowestPrice , 'in_stock':inStock}}, multi=True)
|
100 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':lowestPrice , 'in_stock':inStock}}, multi=True)
|