Subversion Repositories SmartDukaan

Rev

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

Rev 18062 Rev 18086
Line 27... Line 27...
27
from dtr.storage import MemCache
27
from dtr.storage import MemCache
28
from dtr.storage.Mongo import getDealRank
28
from dtr.storage.Mongo import getDealRank
29
 
29
 
30
AFFLIATE_TRASACTIONS_URL = "https://admin.optimisemedia.com/v2/reports/affiliate/leads/leadsummaryexport.aspx?Contact=796881&Country=26&Agency=95&Merchant=420562&Status=-1&Year=%d&Month=%d&Day=%d&EndYear=%d&EndMonth=%d&EndDay=%d&DateType=0&Sort=CompletionDate&Login=1347562DA5E3EFF6FB1561765C47C782&Format=XML&RestrictURL=0"
30
AFFLIATE_TRASACTIONS_URL = "https://admin.optimisemedia.com/v2/reports/affiliate/leads/leadsummaryexport.aspx?Contact=796881&Country=26&Agency=95&Merchant=420562&Status=-1&Year=%d&Month=%d&Day=%d&EndYear=%d&EndMonth=%d&EndDay=%d&DateType=0&Sort=CompletionDate&Login=1347562DA5E3EFF6FB1561765C47C782&Format=XML&RestrictURL=0"
31
ORDER_TRACK_URL='http://www.shopclues.com/index.php?dispatch=order_lookup.details'
31
ORDER_TRACK_URL='http://www.shopclues.com/index.php?dispatch=order_lookup.details'
32
ORDER_TRACK_URL_DB='https://sm.shopclues.com/trackOrder?'
32
ORDER_TRACK_URL_DB='https://smo.shopclues.com/msgorderdetails?'
33
BASE_URL= 'http://www.shopclues.com'
33
BASE_URL= 'http://www.shopclues.com'
34
BASE_MURL= 'http://m.shopclues.com'
34
BASE_MURL= 'http://m.shopclues.com'
35
 
35
 
36
class Store(MStore):
36
class Store(MStore):
37
    
37
    
Line 453... Line 453...
453
            emailId = None
453
            emailId = None
454
            orderObj = None
454
            orderObj = None
455
            merchantOrderId = None
455
            merchantOrderId = None
456
            for script in rawHtmlSoup.find_all('script'):
456
            for script in rawHtmlSoup.find_all('script'):
457
                if 'orderConfirmation' in script.text:
457
                if 'orderConfirmation' in script.text:
458
                    print script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0]
458
                    print script.text.strip().split('\n')[0].split('orderConfirmation = ')[1]
459
                    orderObj = json.loads(script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0])
459
                    orderStr = script.text.strip().split('\n')[0].split('orderConfirmation = ')[1]
-
 
460
                    orderStr = orderStr[:-1]
-
 
461
                    orderObj = json.loads(orderStr)
460
                    if merchantOrderId is None:
462
                    if merchantOrderId is None:
461
                        merchantOrderId = orderObj['0']['order_id']
463
                        merchantOrderId = orderObj['0']['order_id']
462
                        emailId = orderObj['0']['email']
464
                        emailId = orderObj['0']['email']
463
            if orderObj is None or merchantOrderId is None:
465
            if orderObj is None or merchantOrderId is None:
464
                orderIdDiv = rawHtmlSoup.body.find("div", {'class':'conf_succes'})
466
                orderIdDiv = rawHtmlSoup.body.find("div", {'class':'conf_succes'})
Line 474... Line 476...
474
                            return resp
476
                            return resp
475
                    else:
477
                    else:
476
                        orderIdDiv= orderIdArt.find('p', recursive=False)
478
                        orderIdDiv= orderIdArt.find('p', recursive=False)
477
                        orderIdVal = str(orderIdDiv.text.split(' : ')[1])
479
                        orderIdVal = str(orderIdDiv.text.split(' : ')[1])
478
                        print "Opening Shopclues Login Page"
480
                        print "Opening Shopclues Login Page"
479
                        login_url = "https://sm.shopclues.com/login"
481
                        login_url = "https://smo.shopclues.com/login"
480
                        br1 = login(login_url)
482
                        br1 = login(login_url)
481
                        orderDetailPage = br1.open("https://sm.shopclues.com/orderconfirmation?order_id="+orderIdVal+"&status=P")
483
                        orderDetailPage = br1.open("https://smo.shopclues.com/orderconfirmation?order_id="+orderIdVal+"&status=P")
482
                        orderDetailPage = ungzipResponse(orderDetailPage)
484
                        orderDetailPage = ungzipResponse(orderDetailPage)
483
                        rawHtmlSoup = BeautifulSoup(orderDetailPage)
485
                        rawHtmlSoup = BeautifulSoup(orderDetailPage)
484
                        for script in rawHtmlSoup.find_all('script'):
486
                        for script in rawHtmlSoup.find_all('script'):
485
                            if 'orderConfirmation' in script.text:
487
                            if 'orderConfirmation' in script.text:
486
                                orderObj = json.loads(script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0])
488
                                orderObj = json.loads(script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0])
487
                                if merchantOrderId is None:
489
                                if merchantOrderId is None:
488
                                    merchantOrderId = orderObj['0']['order_id']
490
                                    merchantOrderId = orderObj['0']['order_id']
489
                                    emailId = orderObj['0']['email']
491
                                    emailId = orderObj['0']['email']
490
                        logoutpage = br1.open("https://sm.shopclues.com/logout")
492
                        logoutpage = br1.open("https://smo.shopclues.com/logout")
491
                        print br1.geturl()
493
                        print br1.geturl()
492
                else:
494
                else:
493
                    orderIdDiv= orderIdDiv.find('div', recursive=False)
495
                    orderIdDiv= orderIdDiv.find('div', recursive=False)
494
                    orderIdVal = str(orderIdDiv.span.text)
496
                    orderIdVal = str(orderIdDiv.span.text)
495
                    print "Opening Shopclues Login Page"
497
                    print "Opening Shopclues Login Page"
496
                    login_url = "https://sm.shopclues.com/login"
498
                    login_url = "https://smo.shopclues.com/login"
497
                    br1 = login(login_url)
499
                    br1 = login(login_url)
498
                    orderDetailPage = br1.open("https://sm.shopclues.com/orderconfirmation?order_id="+orderIdVal+"&status=P")
500
                    orderDetailPage = br1.open("https://smo.shopclues.com/orderconfirmation?order_id="+orderIdVal+"&status=P")
499
                    orderDetailPage = ungzipResponse(orderDetailPage)
501
                    orderDetailPage = ungzipResponse(orderDetailPage)
500
                    rawHtmlSoup = BeautifulSoup(orderDetailPage)
502
                    rawHtmlSoup = BeautifulSoup(orderDetailPage)
501
                    for script in rawHtmlSoup.find_all('script'):
503
                    for script in rawHtmlSoup.find_all('script'):
502
                        if 'orderConfirmation' in script.text:
504
                        if 'orderConfirmation' in script.text:
503
                            orderObj = json.loads(script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0])
505
                            orderObj = json.loads(script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0])
504
                            if merchantOrderId is None:
506
                            if merchantOrderId is None:
505
                                merchantOrderId = orderObj['0']['order_id']
507
                                merchantOrderId = orderObj['0']['order_id']
506
                                emailId = orderObj['0']['email']
508
                                emailId = orderObj['0']['email']
507
                    logoutpage = br1.open("https://sm.shopclues.com/logout")
509
                    logoutpage = br1.open("https://smo.shopclues.com/logout")
508
                    print br1.geturl()
510
                    print br1.geturl()
509
                    
511
                    
510
            if type(orderObj['0']['items']) is list:
512
            if type(orderObj['0']['items']) is list:
511
                print "Opening Shopclues Login Page"
513
                print "Opening Shopclues Login Page"
512
                login_url = "https://sm.shopclues.com/login"
514
                login_url = "https://smo.shopclues.com/login"
513
                br1 = login(login_url)
515
                br1 = login(login_url)
514
                orderDetailPage = br1.open("https://sm.shopclues.com/orderconfirmation?order_id="+str(merchantOrderId)+"&status=P")
516
                orderDetailPage = br1.open("https://smo.shopclues.com/orderconfirmation?order_id="+str(merchantOrderId)+"&status=P")
515
                orderDetailPage = ungzipResponse(orderDetailPage)
517
                orderDetailPage = ungzipResponse(orderDetailPage)
516
                rawHtmlSoup = BeautifulSoup(orderDetailPage)
518
                rawHtmlSoup = BeautifulSoup(orderDetailPage)
517
                for script in rawHtmlSoup.find_all('script'):
519
                for script in rawHtmlSoup.find_all('script'):
518
                    if 'orderConfirmation' in script.text:
520
                    if 'orderConfirmation' in script.text:
519
                        orderObj = json.loads(script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0])
521
                        orderObj = json.loads(script.text.strip().split('\n')[0].split('orderConfirmation = ')[1].split(';')[0])
520
                        if merchantOrderId is None:
522
                        if merchantOrderId is None:
521
                            merchantOrderId = orderObj['0']['order_id']
523
                            merchantOrderId = orderObj['0']['order_id']
522
                            emailId = orderObj['0']['email']
524
                            emailId = orderObj['0']['email']
523
                logoutpage = br1.open("https://sm.shopclues.com/logout")
525
                logoutpage = br1.open("https://smo.shopclues.com/logout")
524
                print br1.geturl()
526
                print br1.geturl()
525
                    
527
                    
526
            br = getBrowserObject()
528
            br = getBrowserObject()
527
            url = ORDER_TRACK_URL +'&order_id=' +str(merchantOrderId)+'&email_id='+ emailId
529
            url = ORDER_TRACK_URL +'&order_id=' +str(merchantOrderId)+'&email_id='+ emailId
528
            page = br.open(url)
530
            page = br.open(url)
Line 831... Line 833...
831
                print 'Soup Object not found for this Order', order['orderId'], order['orderTrackingUrl']
833
                print 'Soup Object not found for this Order', order['orderId'], order['orderTrackingUrl']
832
                continue      
834
                continue      
833
            
835
            
834
    '''
836
    '''
835
    def getTrackingUrls(self, userId):
837
    def getTrackingUrls(self, userId):
836
        missingOrderUrls = ['https://sm.shopclues.com/myaccount','https://sm.shopclues.com/myorders']
838
        missingOrderUrls = ['https://smo.shopclues.com/myaccount','https://smo.shopclues.com/myorders']
837
        return missingOrderUrls
839
        return missingOrderUrls
838
    
840
    
839
    def parseMyProfileForEmailId(self, userId, url, rawhtml):
841
    def parseMyProfileForEmailId(self, userId, url, rawhtml):
840
        profileSoup = BeautifulSoup(rawhtml)
842
        profileSoup = BeautifulSoup(rawhtml)
841
        if profileSoup.find('input', {'name':'user_email'}) is not None:
843
        if profileSoup.find('input', {'name':'user_email'}) is not None: