Subversion Repositories SmartDukaan

Rev

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

Rev 16212 Rev 16705
Line 150... Line 150...
150
            except:
150
            except:
151
                self.db.merchantOrder.update({"orderId":order['orderId']}, {"$set":{"parseError":True}})
151
                self.db.merchantOrder.update({"orderId":order['orderId']}, {"$set":{"parseError":True}})
152
                tprint("Could not update " + str(order['orderId']) + ' for store ' + self.getName())
152
                tprint("Could not update " + str(order['orderId']) + ' for store ' + self.getName())
153
                traceback.print_exc()
153
                traceback.print_exc()
154
    def scrapeAffiliate(self, startDate=None, endDate=None):
154
    def scrapeAffiliate(self, startDate=None, endDate=None):
-
 
155
        if startDate==None:
-
 
156
            startDate=2
155
        #get all yesterday's affiliate in pending or cancelled state and update to system
157
        #get all yesterday's affiliate in pending or cancelled state and update to system
156
        offers = []
158
        offers = []
157
        br = getBrowserObject()
159
        br = getBrowserObject()
158
        br.open(AFFILIATE_URL)
160
        br.open(AFFILIATE_URL)
159
        response = br.response()  # copy
161
        response = br.response()  # copy
Line 161... Line 163...
161
        data = {'__FK':token,
163
        data = {'__FK':token,
162
                'email':'saholic1@gmail.com',
164
                'email':'saholic1@gmail.com',
163
                'password':'e8aacf6fc1e3998186a4a8e56e428f66'
165
                'password':'e8aacf6fc1e3998186a4a8e56e428f66'
164
        }
166
        }
165
        br.open(AFFILIATE_LOGIN_URL, urllib.urlencode(data))
167
        br.open(AFFILIATE_LOGIN_URL, urllib.urlencode(data))
166
        for delta in range(1,2):
168
        for delta in range(1,startDate):
167
            yester5date = date.today() - timedelta(delta)
169
            yester5date = date.today() - timedelta(delta)
168
            syester5date = yester5date.strftime('%Y-%m-%d')
170
            syester5date = yester5date.strftime('%Y-%m-%d')
-
 
171
            #print "syester5date", syester5date
169
            for status in [AFF_STATUS_PENDING, AFF_STATUS_CANCELLED, AFF_STATUS_DISAPPROVED,AFF_STATUS_APPROVED]:
172
            for status in [AFF_STATUS_PENDING, AFF_STATUS_CANCELLED, AFF_STATUS_DISAPPROVED,AFF_STATUS_APPROVED]:
-
 
173
                #print "status", status
170
                hasPagination=True
174
                hasPagination=True
171
                pagination = 0
175
                pagination = 0
172
                while hasPagination:
176
                while hasPagination:
173
                    pagination = pagination + 1
177
                    pagination = pagination + 1
174
                    try:
178
                    try:
Line 176... Line 180...
176
                    except:
180
                    except:
177
                        tprint("Could not fetch data for Status %s and date %s and pagination %s"%(status, syester5date, pagination))
181
                        tprint("Could not fetch data for Status %s and date %s and pagination %s"%(status, syester5date, pagination))
178
                        continue
182
                        continue
179
                    page = ungzipResponse(br.response())
183
                    page = ungzipResponse(br.response())
180
                    soup = BeautifulSoup(page,convertEntities=BeautifulSoup.HTML_ENTITIES)
184
                    soup = BeautifulSoup(page,convertEntities=BeautifulSoup.HTML_ENTITIES)
181
                    soup.table
185
                    #print "Soup", soup.table
182
                    try:
186
                    try:
183
                        tableElement = soup.findAll('table', {'class':'report-table fixtable'})[1]
187
                        tableElement = soup.findAll('table', {'class':'report-table fixtable'})[1]
184
                    except:
188
                    except:
185
                        break
189
                        break
186
                    trElements = tableElement.findAll('tr')
190
                    trElements = tableElement.findAll('tr')
Line 448... Line 452...
448
    
452
    
449
    
453
    
450
    
454
    
451
 
455
 
452
    store = getStore(2)
456
    store = getStore(2)
-
 
457
    #store.scrapeAffiliate(60)
453
    store.scrapeAffiliate()
458
    store.scrapeAffiliate()
454
    #store.scrapeStoreOrders()
459
    #store.scrapeStoreOrders()
455
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD3016502908102575&token=0db4c692bacbfbfc158b52358ac9e91e&src=or&pr=1')
460
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD3016502908102575&token=0db4c692bacbfbfc158b52358ac9e91e&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')
461
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD3018701137253850&token=f7402ddcf2b63b37cc6bc528cc115d2f&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')
462
    #store.parseOrderRawHtml(12346, "subtagId", 122324,  "html", 'https://m.flipkart.com/orderresponse?reference_id=OD0019279584515727&token=7d85d8c24d36b5a1efc8008634390c7e&src=or&pr=1')