Subversion Repositories SmartDukaan

Rev

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

Rev 14458 Rev 14459
Line 136... Line 136...
136
                offerDiscount +=   int(re.findall(r'\d+', subTrString)[0])
136
                offerDiscount +=   int(re.findall(r'\d+', subTrString)[0])
137
            elif "Delivery Charges" in subTrString:
137
            elif "Delivery Charges" in subTrString:
138
                deliveryCharges =   re.findall(r'\d+', subTrString)[0]
138
                deliveryCharges =   re.findall(r'\d+', subTrString)[0]
139
            elif "Subtotal" in subTrString:
139
            elif "Subtotal" in subTrString:
140
                if int(qty) > 0:
140
                if int(qty) > 0:
141
                    amountPaid =   str(int(re.findall(r'\d+', subTrString)[0]))
141
                    amountPaid =   int(re.findall(r'\d+', subTrString)[0])/qty
142
                else:
142
                else:
143
                    amountPaid =   "0"
143
                    amountPaid =   0
144
        if qty>0:
144
        if qty>0:
145
            if offerDiscount == 0:
145
            if offerDiscount == 0:
146
                amount = int(unitPrice)*int(qty)
146
                amount = int(unitPrice)
147
            else:
147
            else:
148
                amount = int(unitPrice)*int(qty) - offerDiscount
148
                amount = int(unitPrice) - offerDiscount
149
                
149
                
150
        divs = subOrderElement.findAll("div", {"class": "blk lrPad subordrs"})
150
        div1 = subOrderElement.find("div", {"class": "blk lrPad subordrs"})
151
        if len(divs)<=0:
151
        if div1 is None:
152
            raise ParseException("subOrder", "Could not Parse suborders for Snapdeal")
152
            raise ParseException("subOrder", "Could not Parse suborders for Snapdeal")
153
        
153
        
-
 
154
        for strDiv in str(div1).split("<div class=\"seperator\"></div>"):
154
        for div in divs:
155
            div = BeautifulSoup(strDiv)
155
            productTitle = str(subOrderElement.find("a").text)
156
            productTitle = str(subOrderElement.find("a").text)
156
            productUrl = "http://m.snapdeal.com/" + productUrl 
157
            productUrl = "http://m.snapdeal.com/" + productUrl 
157
            subOrder = SubOrder(productTitle, productUrl, placedOn, amountPaid)
158
            subOrder = SubOrder(productTitle, productUrl, placedOn, amountPaid)
158
 
159
 
159
            subOrder.amountPaid = amountPaid
160
            subOrder.amountPaid = amountPaid
Line 405... Line 406...
405
    #print todict([1,2,"3"])
406
    #print todict([1,2,"3"])
406
    store = getStore(3)
407
    store = getStore(3)
407
    #store.scrapeStoreOrders()
408
    #store.scrapeStoreOrders()
408
    #store._isSubOrderActive(8, "5970688907")
409
    #store._isSubOrderActive(8, "5970688907")
409
    #store.scrapeAffiliate()
410
    #store.scrapeAffiliate()
410
    store.parseOrderRawHtml(123456, "subtagId111", 1223231,  "html", 'https://m.snapdeal.com/purchaseMobileComplete?code=0b7af8c6fd24bab5f8e76fe31e1d8953&order=5249356810')
411
    store.parseOrderRawHtml(123456, "subtagId111", 1223231,  "html", 'https://m.snapdeal.com/purchaseMobileComplete?order=5308508434&code=264703b619f8f08f1e1ce7dc42188708')
411
 
-
 
412
 
412
 
413
 
413
 
-
 
414
            
414
def todict(obj, classkey=None):
415
def todict(obj, classkey=None):
415
    if isinstance(obj, dict):
416
    if isinstance(obj, dict):
416
        data = {}
417
        data = {}
417
        for (k, v) in obj.items():
418
        for (k, v) in obj.items():
418
            data[k] = todict(v, classkey)
419
            data[k] = todict(v, classkey)