| Line 142... |
Line 142... |
| 142 |
inStock = 1
|
142 |
inStock = 1
|
| 143 |
identfier = tag['id'].split('_')[1]
|
143 |
identfier = tag['id'].split('_')[1]
|
| 144 |
available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
|
144 |
available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
|
| 145 |
thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
|
145 |
thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
|
| 146 |
print productUrl, source_product_name, thumbnail, rank, available_price, identfier, inStock
|
146 |
print productUrl, source_product_name, thumbnail, rank, available_price, identfier, inStock
|
| 147 |
r_info = __RankInfo(identfier, rank, None , available_price, inStock, thumbnail, source_product_name, productUrl)
|
147 |
r_info = __RankInfo(identfier, rank, "Mobile" , available_price, inStock, thumbnail, source_product_name, productUrl)
|
| 148 |
bestSellers.append(r_info)
|
148 |
bestSellers.append(r_info)
|
| 149 |
|
149 |
|
| 150 |
def scrapeBestSellerTablets():
|
150 |
def scrapeBestSellerTablets():
|
| 151 |
global bestSellers
|
151 |
global bestSellers
|
| 152 |
rank = 0
|
152 |
rank = 0
|
| Line 169... |
Line 169... |
| 169 |
inStock = 1
|
169 |
inStock = 1
|
| 170 |
identfier = tag['id'].split('_')[1]
|
170 |
identfier = tag['id'].split('_')[1]
|
| 171 |
available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
|
171 |
available_price = long(tag.find('p',{'class':'price clearfix'}).find('b').text.split(' ')[1])
|
| 172 |
thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
|
172 |
thumbnail = tag.find('p',{'class':'product_image'}).find('img').get('data-original')
|
| 173 |
print productUrl, source_product_name, thumbnail, rank, available_price, identfier, inStock
|
173 |
print productUrl, source_product_name, thumbnail, rank, available_price, identfier, inStock
|
| 174 |
r_info = __RankInfo(identfier, rank, None , available_price, inStock, thumbnail, source_product_name, productUrl)
|
174 |
r_info = __RankInfo(identfier, rank, "Tablets" , available_price, inStock, thumbnail, source_product_name, productUrl)
|
| 175 |
bestSellers.append(r_info)
|
175 |
bestSellers.append(r_info)
|
| 176 |
|
176 |
|
| 177 |
def resetRanks(category_id):
|
177 |
def resetRanks(category_id):
|
| 178 |
get_mongo_connection().Catalog.MasterData.update({'rank':{'$gt':0},'source_id':7,'category_id':category_id}, {'$set':{'rank':0}}, upsert=False, multi=True)
|
178 |
get_mongo_connection().Catalog.MasterData.update({'rank':{'$gt':0},'source_id':7,'category_id':category_id}, {'$set':{'rank':0}}, upsert=False, multi=True)
|
| 179 |
|
179 |
|
| Line 185... |
Line 185... |
| 185 |
<thead>
|
185 |
<thead>
|
| 186 |
<tr><th>Identifier</th>
|
186 |
<tr><th>Identifier</th>
|
| 187 |
<th>Category</th>
|
187 |
<th>Category</th>
|
| 188 |
<th>Rank</th>
|
188 |
<th>Rank</th>
|
| 189 |
<th>Available_price</th>
|
189 |
<th>Available_price</th>
|
| 190 |
<th>Gross_price</th>
|
- |
|
| 191 |
<th>In_stock</th>
|
190 |
<th>In_stock</th>
|
| 192 |
<th>Coupon</th>
|
- |
|
| 193 |
<th>Thumbnail</th>
|
191 |
<th>Thumbnail</th>
|
| 194 |
<th>Source_product_name</th>
|
192 |
<th>Source_product_name</th>
|
| 195 |
<th>MarketPlaceUrl</th>
|
193 |
<th>MarketPlaceUrl</th>
|
| 196 |
<th>Cod</th>
|
- |
|
| 197 |
</tr></thead>
|
194 |
</tr></thead>
|
| 198 |
<tbody>"""
|
195 |
<tbody>"""
|
| 199 |
for item in exceptionList:
|
196 |
for item in exceptionList:
|
| 200 |
try:
|
197 |
try:
|
| 201 |
message+="""<tr>
|
198 |
message+="""<tr>
|
| 202 |
<td style="text-align:center">"""+(item.identifier)+"""</td>
|
199 |
<td style="text-align:center">"""+(item.identifier)+"""</td>
|
| 203 |
<td style="text-align:center">"""+(item.category)+"""</td>
|
200 |
<td style="text-align:center">"""+str(item.category)+"""</td>
|
| 204 |
<td style="text-align:center">"""+str(item.rank)+"""</td>
|
201 |
<td style="text-align:center">"""+str(item.rank)+"""</td>
|
| 205 |
<td style="text-align:center">"""+str(item.available_price)+"""</td>
|
202 |
<td style="text-align:center">"""+str(item.available_price)+"""</td>
|
| 206 |
<td style="text-align:center">"""+str(item.gross_price)+"""</td>
|
- |
|
| 207 |
<td style="text-align:center">"""+str(item.in_stock)+"""</td>
|
203 |
<td style="text-align:center">"""+str(item.in_stock)+"""</td>
|
| 208 |
<td style="text-align:center">"""+str(item.coupon)+"""</td>
|
- |
|
| 209 |
<td style="text-align:center">"""+str(item.thumbnail)+"""</td>
|
204 |
<td style="text-align:center">"""+str(item.thumbnail)+"""</td>
|
| 210 |
<td style="text-align:center">"""+str(item.source_product_name)+"""</td>
|
205 |
<td style="text-align:center">"""+str(item.source_product_name)+"""</td>
|
| 211 |
<td style="text-align:center">"""+str(item.marketPlaceUrl)+"""</td>
|
206 |
<td style="text-align:center">"""+str(item.marketPlaceUrl)+"""</td>
|
| 212 |
<td style="text-align:center">"""+str(item.cod)+"""</td>
|
- |
|
| 213 |
</tr>"""
|
207 |
</tr>"""
|
| 214 |
except:
|
208 |
except:
|
| 215 |
continue
|
209 |
continue
|
| 216 |
message+="""</tbody></table></body></html>"""
|
210 |
message+="""</tbody></table></body></html>"""
|
| 217 |
print message
|
211 |
print message
|