Subversion Repositories SmartDukaan

Rev

Rev 19665 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19665 Rev 20002
Line 453... Line 453...
453
        return merchantOrder
453
        return merchantOrder
454
        
454
        
455
    def parseOrderRawHtml(self, orderId, subTagId, userId, rawHtml, orderSuccessUrl):
455
    def parseOrderRawHtml(self, orderId, subTagId, userId, rawHtml, orderSuccessUrl):
456
        resp = {}
456
        resp = {}
457
        try:
457
        try:
458
            rawHtmlSoup = BeautifulSoup(rawHtml)
458
            dummySoup = BeautifulSoup(rawHtml)
-
 
459
            orderIdSpan = dummySoup.find('div',{'class':'description'}).find('span').text
-
 
460
            temp_order_id = re.findall('\d+', orderIdSpan)[0]
-
 
461
            login_url = "https://smo.shopclues.com/login"
-
 
462
            br_temp = login(login_url)
-
 
463
            orderDetailPage = br_temp.open("https://smo.shopclues.com/orderconfirmation?order_id="+str(temp_order_id)+"&status=P")
-
 
464
            orderDetailPage = ungzipResponse(orderDetailPage)
-
 
465
            rawHtmlSoup = BeautifulSoup(orderDetailPage)
-
 
466
            br_temp.open("https://smo.shopclues.com/logout")
459
            emailId = None
467
            emailId = None
460
            orderObj = None
468
            orderObj = None
461
            merchantOrderId = None
469
            merchantOrderId = None
462
            for script in rawHtmlSoup.find_all('script'):
470
            for script in rawHtmlSoup.find_all('script'):
463
                if 'orderConfirmation' in script.text:
471
                if 'orderConfirmation' in script.text:
464
                    orderStr = script.text.strip().split('\n')[0].split('orderConfirmation = ')[1]
472
                    orderStr = script.text.strip().split('\n')[0].split('orderConfirmation = ')[1]
465
                    orderStr = orderStr[:-1]
473
                    orderStr = orderStr[:-2]
466
                    orderObj = json.loads(orderStr)
474
                    orderObj = json.loads(orderStr)
467
                    if merchantOrderId is None:
475
                    if merchantOrderId is None:
468
                        merchantOrderId = orderObj['0']['order_id']
476
                        merchantOrderId = orderObj['0']['order_id']
469
                        emailId = orderObj['0']['email']
477
                        emailId = orderObj['0']['email']
470
            if orderObj is None or merchantOrderId is None:
478
            if orderObj is None or merchantOrderId is None:
Line 901... Line 909...
901
    br.open(url)
909
    br.open(url)
902
    response = br.open(url)
910
    response = br.open(url)
903
    ungzipResponseBr(response, br)
911
    ungzipResponseBr(response, br)
904
    #html = response.read()
912
    #html = response.read()
905
    #print html
913
    #print html
-
 
914
    formcount = 0
-
 
915
    for frm in br.forms():  
-
 
916
        if str(frm.attrs["id"])=="login":
-
 
917
            break
-
 
918
        formcount=formcount+1
906
    br.select_form(nr=0)
919
    br.select_form(nr=formcount)
907
    br.form['user'] = "imanthetester@gmail.com"
920
    br.form['user'] = "imanthetester@gmail.com"
908
    br.form['password'] = "$Dl8uk"
921
    br.form['password'] = "$Dl8uk"
909
    response = br.submit()
922
    response = br.submit()
910
    print "********************"
923
    print "********************"
911
    print "Attempting to Login"
924
    print "Attempting to Login"