Subversion Repositories SmartDukaan

Rev

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

Rev 16209 Rev 16210
Line 161... Line 161...
161
        data = {'__FK':token,
161
        data = {'__FK':token,
162
                'email':'saholic1@gmail.com',
162
                'email':'saholic1@gmail.com',
163
                'password':'e8aacf6fc1e3998186a4a8e56e428f66'
163
                'password':'e8aacf6fc1e3998186a4a8e56e428f66'
164
        }
164
        }
165
        br.open(AFFILIATE_LOGIN_URL, urllib.urlencode(data))
165
        br.open(AFFILIATE_LOGIN_URL, urllib.urlencode(data))
166
        for delta in range(1,2):
166
        for delta in range(1,126):
167
            yester5date = date.today() - timedelta(delta)
167
            yester5date = date.today() - timedelta(delta)
168
            syester5date = yester5date.strftime('%Y-%m-%d')
168
            syester5date = yester5date.strftime('%Y-%m-%d')
169
            for status in [AFF_STATUS_PENDING, AFF_STATUS_CANCELLED, AFF_STATUS_DISAPPROVED,AFF_STATUS_APPROVED]:
169
            for status in [AFF_STATUS_PENDING, AFF_STATUS_CANCELLED, AFF_STATUS_DISAPPROVED,AFF_STATUS_APPROVED]:
170
                hasPagination=True
170
                hasPagination=True
171
                pagination = 0
171
                pagination = 0
Line 182... Line 182...
182
                        tableElement = soup.findAll('table', {'class':'report-table fixtable'})[1]
182
                        tableElement = soup.findAll('table', {'class':'report-table fixtable'})[1]
183
                    except:
183
                    except:
184
                        break
184
                        break
185
                    trElements = tableElement.findAll('tr')
185
                    trElements = tableElement.findAll('tr')
186
                    trElements.pop(0)
186
                    trElements.pop(0)
187
                        
187
                    tprint("Successfully updated fetch data for Status %s and date %s and pagination %s"%(status, syester5date, pagination))
188
                    for trElement in trElements:
188
                    for trElement in trElements:
189
                        tdElements = trElement.findAll('td')
189
                        tdElements = trElement.findAll('td')
190
                        if tdElements[0].text.strip()=='No Products to display!':
190
                        if tdElements[0].text.strip()=='No Products to display!':
191
                            hasPagination = False
191
                            hasPagination = False
192
                            continue
192
                            continue
Line 200... Line 200...
200
                        affiliateInfo = FlipkartAffiliateInfo(subTagId, syester5date, productCode, price, quantity, saleAmount, payOut, status, category)
200
                        affiliateInfo = FlipkartAffiliateInfo(subTagId, syester5date, productCode, price, quantity, saleAmount, payOut, status, category)
201
                        affiliateInfo.productTitle =  tdElements[0].find('a').text
201
                        affiliateInfo.productTitle =  tdElements[0].find('a').text
202
                        #updateMap['subOrders.$.unitPrice'] = price
202
                        #updateMap['subOrders.$.unitPrice'] = price
203
                        #updateMap['subOrders.$.cashBackAmount'], updateMap['subOrders.$.cashBacPercentage'] = self.getCashbackAmount(productCode, price)
203
                        #updateMap['subOrders.$.cashBackAmount'], updateMap['subOrders.$.cashBacPercentage'] = self.getCashbackAmount(productCode, price)
204
                        offers.append(affiliateInfo)
204
                        offers.append(affiliateInfo)
205
                        tprint("Successfully updated fetch data for Status %s and date %s and pagination %s"%(status, syester5date, pagination))
-
 
206
        self._saveToAffiliate(offers)
205
                self._saveToAffiliate(offers)
207
        
206
        
208
        yester5date = date.today() - timedelta(1)
207
        yester5date = date.today() - timedelta(1)
209
        syester5date = yester5date.strftime('%Y-%m-%d')
208
        syester5date = yester5date.strftime('%Y-%m-%d')
210
        self.db.flipkartOrderAffiliateInfo.find({"saleDate":syester5date})
209
        self.db.flipkartOrderAffiliateInfo.find({"saleDate":syester5date})
211
        for order in self.db.flipkartOrderAffiliateInfo.find({"saleDate":syester5date}):
210
        for order in self.db.flipkartOrderAffiliateInfo.find({}):
212
            userId = None
211
            userId = None
213
            subTagId = None
212
            subTagId = None
214
            email = None
213
            email = None
215
            subTagId = order.get("subTagId")
214
            subTagId = order.get("subTagId")
216
            if subTagId:
215
            if subTagId:
Line 443... Line 442...
443
def hex_md5(password):
442
def hex_md5(password):
444
    m = hashlib.md5()
443
    m = hashlib.md5()
445
    print(m.digest())
444
    print(m.digest())
446
 
445
 
447
def main():
446
def main():
448
    requestDownload()
447
    #requestDownload()
449
    
448
    
450
    
449
    
451
    
450
    
452
 
451
 
453
    #store = getStore(2)
452
    store = getStore(2)
454
    #store.scrapeAffiliate()
453
    store.scrapeAffiliate()
455
    #store.scrapeStoreOrders()
454
    #store.scrapeStoreOrders()
456
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD3016502908102575&token=0db4c692bacbfbfc158b52358ac9e91e&src=or&pr=1')
455
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD3016502908102575&token=0db4c692bacbfbfc158b52358ac9e91e&src=or&pr=1')
457
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD3018701137253850&token=f7402ddcf2b63b37cc6bc528cc115d2f&src=or&pr=1')
456
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD3018701137253850&token=f7402ddcf2b63b37cc6bc528cc115d2f&src=or&pr=1')
458
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD0019279584515727&token=7d85d8c24d36b5a1efc8008634390c7e&src=or&pr=1')
457
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD0019279584515727&token=7d85d8c24d36b5a1efc8008634390c7e&src=or&pr=1')
459
    #store.flipkartOrderTracking(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD0019279584515727&token=7d85d8c24d36b5a1efc8008634390c7e&src=or&pr=1')
458
    #store.flipkartOrderTracking(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD0019279584515727&token=7d85d8c24d36b5a1efc8008634390c7e&src=or&pr=1')