Subversion Repositories SmartDukaan

Rev

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

Rev 12853 Rev 12908
Line 50... Line 50...
50
        else:
50
        else:
51
            raise
51
            raise
52
    
52
    
53
    def parse_product_category_for_sku(self,response):
53
    def parse_product_category_for_sku(self,response):
54
        browseNodes = []
54
        browseNodes = []
55
        node = "" 
55
        #node = "" 
56
        spString = re.sub('<\?.*\?>','',response.text)
56
        spString = re.sub('<\?.*\?>','',response.text)
57
        spString = "<dom>" + spString + "</dom>"
57
        spString = "<dom>" + spString + "</dom>"
58
        dom = parseString(spString)
58
        dom = parseString(spString)
59
        selfTag = dom.getElementsByTagName('Self')
59
        selfTag = dom.getElementsByTagName('Self')
60
        for element in selfTag:
60
        for element in selfTag:
Line 62... Line 62...
62
            browsingNodes = element.getElementsByTagName('ProductCategoryName')
62
            browsingNodes = element.getElementsByTagName('ProductCategoryName')
63
            for browsingNode in browsingNodes:
63
            for browsingNode in browsingNodes:
64
                temp.append(browsingNode.firstChild.nodeValue)
64
                temp.append(browsingNode.firstChild.nodeValue)
65
            browseNodes.append(temp)
65
            browseNodes.append(temp)
66
        return browseNodes
66
        return browseNodes
67
#        for browseNode in browseNodes:
-
 
68
#            node+=browseNode+'>'
-
 
69
#        return node[:-1]
-
 
70
            
-
 
71
        
-
 
72
    
67
    
73
    def parse_competitor_pricing_response(self,response):
68
    def parse_competitor_pricing_response(self,response):
74
        spString = re.sub('<\?.*\?>','',response.text)
69
        spString = re.sub('<\?.*\?>','',response.text)
75
        spString = "<dom>" + spString + "</dom>"
70
        spString = "<dom>" + spString + "</dom>"
76
        dom = parseString(spString)
71
        dom = parseString(spString)
Line 165... Line 160...
165
        for skuOffer in skuOffers:
160
        for skuOffer in skuOffers:
166
            try:
161
            try:
167
                status = skuOffer.attributes.items()[0][1]
162
                status = skuOffer.attributes.items()[0][1]
168
                sku = skuOffer.attributes.items()[1][1]
163
                sku = skuOffer.attributes.items()[1][1]
169
                asin = skuOffer.getElementsByTagName('ASIN')[0].firstChild.nodeValue
164
                asin = skuOffer.getElementsByTagName('ASIN')[0].firstChild.nodeValue
-
 
165
                skuMap[sku]={}
170
            except:
166
            except:
171
                continue
167
                continue
172
            for offer in skuOffer.getElementsByTagName('Offers'):
168
            for offer in skuOffer.getElementsByTagName('Offer'):
-
 
169
                offerSku = offer.getElementsByTagName('SellerSKU')[0].firstChild.nodeValue
-
 
170
                fcChannel =  offer.getElementsByTagName('FulfillmentChannel')[0].firstChild.nodeValue
-
 
171
                if not (offerSku==sku and fcChannel=='AMAZON'):
-
 
172
                    continue
173
                temp = {}
173
                temp = {}
174
                try:
174
                try:
175
                    promoPrice = offer.getElementsByTagName('LandedPrice')[0].getElementsByTagName('Amount')[0].firstChild.nodeValue
175
                    promoPrice = offer.getElementsByTagName('LandedPrice')[0].getElementsByTagName('Amount')[0].firstChild.nodeValue
176
                    regularPrice = offer.getElementsByTagName('RegularPrice')[0].getElementsByTagName('Amount')[0].firstChild.nodeValue
176
                    regularPrice = offer.getElementsByTagName('RegularPrice')[0].getElementsByTagName('Amount')[0].firstChild.nodeValue
177
                    temp['sellingPrice'] = float(regularPrice)
177
                    temp['sellingPrice'] = float(regularPrice)
Line 232... Line 232...
232
    
232
    
233
    
233
    
234
def main():
234
def main():
235
    p = Products("AKIAII3SGRXBJDPCHSGQ", "B92xTbNBTYygbGs98w01nFQUhbec1pNCkCsKVfpg", "AF6E3O0VE0X4D")
235
    p = Products("AKIAII3SGRXBJDPCHSGQ", "B92xTbNBTYygbGs98w01nFQUhbec1pNCkCsKVfpg", "AF6E3O0VE0X4D")
236
    #comp = p.get_competitive_pricing_for_sku('A21TJRUUN4KGV', ['FBA5791'])
236
    #comp = p.get_competitive_pricing_for_sku('A21TJRUUN4KGV', ['FBA5791'])
237
    #our = p.get_my_pricing_for_sku('A21TJRUUN4KGV', ["FBB17254"])
237
    our = p.get_my_pricing_for_sku('A21TJRUUN4KGV', ["FBG10570"])
-
 
238
    print our
238
    cat = p.get_product_category_for_sku('A21TJRUUN4KGV', "FBA5791")
239
    #cat = p.get_product_category_for_sku('A21TJRUUN4KGV', "FBA16803")
239
    print cat
240
    #print cat
240
    #print our
241
    #print our
241
    #print comp
242
    #print comp
242
#    for k, v in our.iteritems():
243
#    for k, v in our.iteritems():
243
#        print k,
244
#        print k,
244
#        print '\t',
245
#        print '\t',