Subversion Repositories SmartDukaan

Rev

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

Rev 12285 Rev 12286
Line 116... Line 116...
116
                        ourSp = vendor['sellingPrice']
116
                        ourSp = vendor['sellingPrice']
117
                    ourOfferPrice = vendor['sellingPrice']
117
                    ourOfferPrice = vendor['sellingPrice']
118
                iterator+=1
118
                iterator+=1
119
        except:
119
        except:
120
            continue
120
            continue
-
 
121
        finally:
-
 
122
            sdItem, snapdealItem =None, None
121
        snapdealItem.ourSnapdealPrice = ourSp
123
        snapdealItem.ourSnapdealPrice = ourSp
122
        snapdealItem.ourSnapdealOfferPrice = ourOfferPrice
124
        snapdealItem.ourSnapdealOfferPrice = ourOfferPrice
123
        snapdealItem.ourSnapdealInventory = ourInventory
125
        snapdealItem.ourSnapdealInventory = ourInventory
124
        snapdealItem.lowestSnapdealPrice = lowestSp
126
        snapdealItem.lowestSnapdealPrice = lowestSp
125
        snapdealItem.lowestSnapdealOfferPrice = lowestOfferPrice
127
        snapdealItem.lowestSnapdealOfferPrice = lowestOfferPrice
Line 148... Line 150...
148
                    ourSp = data['sellingPrice']
150
                    ourSp = data['sellingPrice']
149
 
151
 
150
                iterator+=1
152
                iterator+=1
151
        except:
153
        except:
152
            continue
154
            continue
153
        
155
        finally:
-
 
156
            fkItem, flipkartItem=None,None
154
        try:
157
        try:
155
            request_url = "https://api.flipkart.net/sellers/skus/%s/listings"%(str(fkItem.flipkartSerialNumber))
158
            request_url = "https://api.flipkart.net/sellers/skus/%s/listings"%(str(fkItem.flipkartSerialNumber))
156
            r = httpRequest.get(request_url, auth=('m2z93iskuj81qiid', '0c7ab6a5-98c0-4cdc-8be3-72c591e0add4'))
159
            r = httpRequest.get(request_url, auth=('m2z93iskuj81qiid', '0c7ab6a5-98c0-4cdc-8be3-72c591e0add4'))
157
            print "Inventory info",r.json()
160
            print "Inventory info",r.json()
158
            stock_count = int((r.json()['attributeValues'])['stock_count'])
161
            stock_count = int((r.json()['attributeValues'])['stock_count'])
Line 196... Line 199...
196
                asin=fbaAsin
199
                asin=fbaAsin
197
            url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(asin)
200
            url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(asin)
198
            scraperAmazon.read(url,True)
201
            scraperAmazon.read(url,True)
199
            lowestSp,lowestSeller = scraperAmazon.createData()
202
            lowestSp,lowestSeller = scraperAmazon.createData()
200
            amazonItem.lowestAmazonPrice = lowestSp
203
            amazonItem.lowestAmazonPrice = lowestSp
201
            
-
 
202
            print "Details of Item id ",amazonItem.item_id
-
 
203
            print "ASIN ",asin
-
 
204
            print "MFN INVENTORY ",mfnInventory
-
 
205
            print "FBA INVENTORY ",fbaInventory
-
 
206
            print "MFN PRICE ",mfnPrice
-
 
207
            print "FBA PRICE ",fbaPrice
-
 
208
            print "Lowest Seller SP ",lowestSp
-
 
209
            print "LOWEST SELLER NAME ",lowestSeller
-
 
210
            
-
 
211
            amazonItem.ourMfnPrice = float(str(mfnPrice).replace("Rs.","").replace(",",""))
204
            amazonItem.ourMfnPrice = float(str(mfnPrice).replace("Rs.","").replace(",",""))
212
            amazonItem.ourFbaPrice = float(str(fbaPrice).replace("Rs.","").replace(",",""))
205
            amazonItem.ourFbaPrice = float(str(fbaPrice).replace("Rs.","").replace(",",""))
213
            amazonItem.ourMfnInventory = int(mfnInventory)
206
            amazonItem.ourMfnInventory = int(mfnInventory)
214
            amazonItem.ourFbaInventory = int(fbaInventory)
207
            amazonItem.ourFbaInventory = int(fbaInventory)
215
            amazonItem.lowestAmazonPrice = float(lowestSp)
208
            amazonItem.lowestAmazonPrice = float(lowestSp)
Line 217... Line 210...
217
 
210
 
218
        except Exception as e:
211
        except Exception as e:
219
            print e
212
            print e
220
            print "Unable to fetch details from Amazon Listing page for ",amazonItem.item_id
213
            print "Unable to fetch details from Amazon Listing page for ",amazonItem.item_id
221
            continue
214
            continue
-
 
215
        finally:
-
 
216
            amazonItem = None
222
    sc =None
217
    sc =None
223
    scraperAmazon = None
218
    scraperAmazon = None
224
        
219
        
225
def getBrowserObject():
220
def getBrowserObject():
226
        br = mechanize.Browser(factory=mechanize.RobustFactory())
221
        br = mechanize.Browser(factory=mechanize.RobustFactory())