Subversion Repositories SmartDukaan

Rev

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

Rev 17068 Rev 17069
Line 88... Line 88...
88
            titleTag = tag.find('p', {'class' : 'product_title'})
88
            titleTag = tag.find('p', {'class' : 'product_title'})
89
            source_product_name = titleTag.text
89
            source_product_name = titleTag.text
90
            productUrl = titleTag.find('a').get('href')
90
            productUrl = titleTag.find('a').get('href')
91
            productUrl = 'http://www.homeshop18.com'+str(productUrl)
91
            productUrl = 'http://www.homeshop18.com'+str(productUrl)
92
            inStock = 1
92
            inStock = 1
93
            identfier = tag['id'].split('_')[1]
93
            identifier = tag['id'].split('_')[1]
94
            available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
94
            available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
95
            thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
95
            thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
96
            print productUrl, source_product_name, thumbnail, rank, available_price, identfier, inStock
96
            print productUrl, source_product_name, thumbnail, rank, available_price, identifier, inStock
97
            r_info = __RankInfo(identfier, rank, None, available_price, inStock, thumbnail, source_product_name, productUrl)
97
            r_info = __RankInfo(identifier, rank, None, available_price, inStock, thumbnail, source_product_name, "http://m.homeshop18.com/product.mobi?productId=%s"%str(identifier))
98
            bestSellers.append(r_info)   
98
            bestSellers.append(r_info)   
99
                
99
                
100
def scrapeBestSellerTablets():
100
def scrapeBestSellerTablets():
101
    global bestSellers
101
    global bestSellers
102
    rank = 0
102
    rank = 0
Line 116... Line 116...
116
            titleTag = tag.find('p', {'class' : 'product_title'})
116
            titleTag = tag.find('p', {'class' : 'product_title'})
117
            source_product_name = titleTag.text
117
            source_product_name = titleTag.text
118
            productUrl = titleTag.find('a').get('href')
118
            productUrl = titleTag.find('a').get('href')
119
            productUrl = 'http://www.homeshop18.com'+str(productUrl)
119
            productUrl = 'http://www.homeshop18.com'+str(productUrl)
120
            inStock = 1
120
            inStock = 1
121
            identfier = tag['id'].split('_')[1]
121
            identifier = tag['id'].split('_')[1]
122
            available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
122
            available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
123
            thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
123
            thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
124
            print productUrl, source_product_name, thumbnail, rank, available_price, identfier, inStock
124
            print productUrl, source_product_name, thumbnail, rank, available_price, identifier, inStock
125
            r_info = __RankInfo(identfier, rank, None , available_price, inStock, thumbnail, source_product_name, productUrl)
125
            r_info = __RankInfo(identifier, rank, None , available_price, inStock, thumbnail, source_product_name, "http://m.homeshop18.com/product.mobi?productId=%s"%str(identifier))
126
            bestSellers.append(r_info)
126
            bestSellers.append(r_info)
127
                
127
                
128
def resetRanks(category_id):
128
def resetRanks(category_id):
129
    get_mongo_connection(host=options.mongoHost).Catalog.MasterData.update({'rank':{'$gt':0},'source_id':7,'category_id':category_id}, {'$set':{'rank':0}}, upsert=False, multi=True)
129
    get_mongo_connection(host=options.mongoHost).Catalog.MasterData.update({'rank':{'$gt':0},'source_id':7,'category_id':category_id}, {'$set':{'rank':0}}, upsert=False, multi=True)
130
 
130