| Line 469... |
Line 469... |
| 469 |
for s in orderJSON['suborders']:
|
469 |
for s in orderJSON['suborders']:
|
| 470 |
print s
|
470 |
print s
|
| 471 |
if not supcMap.has_key(s['supcCode']):
|
471 |
if not supcMap.has_key(s['supcCode']):
|
| 472 |
skuData = Mongo.get_mongo_connection().Catalog.MasterData.find_one({'identifier':s['supcCode'], 'source_id':self.store_id})
|
472 |
skuData = Mongo.get_mongo_connection().Catalog.MasterData.find_one({'identifier':s['supcCode'], 'source_id':self.store_id})
|
| 473 |
if skuData is None:
|
473 |
if skuData is None:
|
| 474 |
url = "http://www.snapdeal.com/search/autoSuggestion?q=%s&catId=0&ver=3"%s['supcCode']
|
474 |
url = "http://www.snapdeal.com/search?keyword=%s"%s['supcCode']
|
| 475 |
html = utils.fetchResponseUsingProxy(url)
|
475 |
html = utils.fetchResponseUsingProxy(url)
|
| 476 |
html = html.replace(" ", "")
|
476 |
html = html.replace(" ", "")
|
| 477 |
ul = PyQuery(html)('ul.top-products')
|
477 |
pq = PyQuery(html)
|
| 478 |
title = PyQuery(ul('div.product-text')[0]).text().strip()
|
478 |
tag = pq('div.product-tuple-listing')
|
| - |
|
479 |
for resultDiv in tag:
|
| 479 |
productUrl = ul('a').attr("href").split("?")[0]
|
480 |
pq_resultDiv = pq(resultDiv)
|
| - |
|
481 |
if (pq_resultDiv.attr['data-defaultsupcforfmcg']).strip() == s['supcCode'].strip():
|
| - |
|
482 |
productUrl = pq_resultDiv('div.product-tuple-image').children('a').attr('href')
|
| - |
|
483 |
imgUrl = pq_resultDiv('div.product-tuple-image').children('a').children('img').attr('src')
|
| - |
|
484 |
title = pq_resultDiv('p.product-title').text()
|
| 480 |
imgUrl = ul('img').attr('src')
|
485 |
break
|
| 481 |
else:
|
486 |
else:
|
| 482 |
title = skuData['product_name']
|
487 |
title = skuData['product_name']
|
| 483 |
productUrl = skuData['marketPlaceUrl']
|
488 |
productUrl = skuData['marketPlaceUrl']
|
| 484 |
imgUrl = skuData['thumbnail']
|
489 |
imgUrl = skuData['thumbnail']
|
| 485 |
supcMap[s['supcCode']] = {'title':title, 'imgUrl':imgUrl, 'productUrl':productUrl}
|
490 |
supcMap[s['supcCode']] = {'title':title, 'imgUrl':imgUrl, 'productUrl':productUrl}
|