Subversion Repositories SmartDukaan

Rev

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

Rev 14872 Rev 14883
Line 106... Line 106...
106
            elif "Offer Discount" in orderTrString:
106
            elif "Offer Discount" in orderTrString:
107
                merchantOrder.discountApplied = re.findall(r'\d+', orderTrString)[0]
107
                merchantOrder.discountApplied = re.findall(r'\d+', orderTrString)[0]
108
 
108
 
109
        merchantSubOrders = []
109
        merchantSubOrders = []
110
        for subOrderElement in subOrders:
110
        for subOrderElement in subOrders:
111
            subOrder = self.parseSubOrderB(subOrderElement, placedOn)                           
111
            subOrder = self.parseSubOrderB(subOrderElement, placedOn)
-
 
112
            if subOrder is not None:
112
            merchantSubOrders.append(subOrder)
113
                merchantSubOrders.append(subOrder)
113
        merchantOrder.subOrders = merchantSubOrders
114
        merchantOrder.subOrders = merchantSubOrders
114
        return merchantOrder
115
        return merchantOrder
115
    
116
    
116
    def _parse(self, orderId, subTagId, userId, page, orderSuccessUrl):
117
    def _parse(self, orderId, subTagId, userId, page, orderSuccessUrl):
117
        
118
        
Line 254... Line 255...
254
 
255
 
255
        paymentDivs = prodDivs[2].findAll('div', recursive=False)
256
        paymentDivs = prodDivs[2].findAll('div', recursive=False)
256
        for paymentDiv in paymentDivs:
257
        for paymentDiv in paymentDivs:
257
            strPaymentDiv = str(paymentDiv)
258
            strPaymentDiv = str(paymentDiv)
258
            if "Unit Price" in strPaymentDiv:
259
            if "Unit Price" in strPaymentDiv:
-
 
260
                try:
259
                unitPrice = int(re.findall(r'\d+', strPaymentDiv)[0])
261
                    unitPrice = int(re.findall(r'\d+', strPaymentDiv)[0])
-
 
262
                except:
-
 
263
                    return None
260
            elif "Offer Discount" in strPaymentDiv:
264
            elif "Offer Discount" in strPaymentDiv:
261
                offerDiscount += int(re.findall(r'\d+', strPaymentDiv)[0])
265
                offerDiscount += int(re.findall(r'\d+', strPaymentDiv)[0])
262
            elif "Discount" in strPaymentDiv:
266
            elif "Discount" in strPaymentDiv:
263
                offerDiscount += int(re.findall(r'\d+', strPaymentDiv)[0])
267
                offerDiscount += int(re.findall(r'\d+', strPaymentDiv)[0])
264
            elif "SD Cash" in strPaymentDiv:
268
            elif "SD Cash" in strPaymentDiv:
Line 481... Line 485...
481
            merchantSubOrderId = prodDivs[0].text.split(':')[1].strip()
485
            merchantSubOrderId = prodDivs[0].text.split(':')[1].strip()
482
            subOrder = None
486
            subOrder = None
483
            subOrder =  self._isSubOrderActive(order, merchantSubOrderId)
487
            subOrder =  self._isSubOrderActive(order, merchantSubOrderId)
484
            if subOrder is None:
488
            if subOrder is None:
485
                try:
489
                try:
486
                    subOrders = self.parseSubOrderB(subOrderElement, placedOn)
490
                    subOrder = self.parseSubOrderB(subOrderElement, placedOn)
-
 
491
                    if subOrder is None:
-
 
492
                        continue
487
                    self.db.merchantOrder.update({"orderId":order['orderId']},{'$push':{"subOrders":{"$each":todict([subOrders])}}})
493
                    self.db.merchantOrder.update({"orderId":order['orderId']},{'$push':{"subOrders":{"$each":todict([subOrder])}}})
488
                    print "Added new suborders to Order id - ", order['orderId']
494
                    print "Added new suborders to Order id - ", order['orderId']
489
                    closed = False
495
                    closed = False
490
                except:
496
                except:
491
                    pass
497
                    pass
492
                continue
498
                continue
Line 616... Line 622...
616
    return urllib.urlencode(parameters)
622
    return urllib.urlencode(parameters)
617
 
623
 
618
def main():
624
def main():
619
    #print todict([1,2,"3"])
625
    #print todict([1,2,"3"])
620
    store = getStore(3)
626
    store = getStore(3)
621
    #store.parseOrderRawHtml(33222, "32323", 2, "323243", "https://m.snapdeal.com/purchaseMobileComplete?code=1131a4add85aefb40a924d71cbf921bd&order=5822561503")
627
    store.parseOrderRawHtml(332221, "3232311", 2, "32311243", "https://m.snapdeal.com/orderSummary?code=1131a4add85aefb40a924d71cbf921bd&order=5822561503")
622
    store.scrapeStoreOrders()
628
    #store.scrapeStoreOrders()
623
    #store._isSubOrderActive(8, "5970688907")
629
    #store._isSubOrderActive(8, "5970688907")
624
    #store.scrapeAffiliate()
630
    #store.scrapeAffiliate()
625
    #store.scrapeStoreOrders()
631
    #store.scrapeStoreOrders()
626
 
632
 
627
 
633