Subversion Repositories SmartDukaan

Rev

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

Rev 13846 Rev 13871
Line 29... Line 29...
29
        print str(data['identifier'])
29
        print str(data['identifier'])
30
        if data['identifier'] is None or len(data['identifier'].strip())==0:
30
        if data['identifier'] is None or len(data['identifier'].strip())==0:
31
            print "continue"
31
            print "continue"
32
            continue
32
            continue
33
        
33
        
34
        url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(data['identifier'])
34
        url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(data['identifier'].strip())
35
        print url
35
        print url
36
        lowestPrice = 0.0
36
        lowestPrice = 0.0
37
        lowestPrice = scraperAmazon.read(url)
37
        lowestPrice = scraperAmazon.read(url)
38
        print lowestPrice
38
        print lowestPrice
39
        if lowestPrice > 0:
39
        if lowestPrice > 0:
40
            inStock = 1
40
            inStock = 1
41
        print lowestPrice
41
        print lowestPrice
42
        print inStock
42
        print inStock
43
        if lowestPrice > 0:
43
        if lowestPrice > 0:
44
            get_mongo_connection().Catalog.MasterData.update({'identifier':data['identifier']}, {'$set' : {'available_price':lowestPrice,'updatedOn':to_java_date(now),'in_stock':inStock}}, multi=True)
44
            get_mongo_connection().Catalog.MasterData.update({'identifier':data['identifier'].strip(),'source_id':1}, {'$set' : {'available_price':lowestPrice,'updatedOn':to_java_date(now),'in_stock':inStock}}, multi=True)
45
        else:
45
        else:
46
            get_mongo_connection().Catalog.MasterData.update({'identifier':data['identifier']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock}}, multi=True)
46
            get_mongo_connection().Catalog.MasterData.update({'identifier':data['identifier'].strip(),'source_id':1}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock}}, multi=True)
47
        print "+++++++++++++++++++++++++++"
47
        print "+++++++++++++++++++++++++++"
48
 
48
 
49
def main():
49
def main():
50
    scrapeAmazon()
50
    scrapeAmazon()
51
            
51