Subversion Repositories SmartDukaan

Rev

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

Rev 15589 Rev 15596
Line 4... Line 4...
4
from dtr.utils.utils import get_mongo_connection
4
from dtr.utils.utils import get_mongo_connection
5
import optparse
5
import optparse
6
 
6
 
7
USER_NAME = "saholic-snapdeal@saholic.com"
7
USER_NAME = "saholic-snapdeal@saholic.com"
8
PASSWORD = "snapsaholic15"
8
PASSWORD = "snapsaholic15"
-
 
9
VOI_USER_NAME = "spiceonlineretailvoi@gmail.com"
-
 
10
VOI_PASSWORD = "saholicsnapdeal1"
9
 
11
 
10
parser = optparse.OptionParser()
12
parser = optparse.OptionParser()
11
parser.add_option("-m", "--m", dest="mongoHost",
13
parser.add_option("-m", "--m", dest="mongoHost",
12
                      default="localhost",
14
                      default="localhost",
13
                      type="string", help="The HOST where the mongo server is running",
15
                      type="string", help="The HOST where the mongo server is running",
Line 59... Line 61...
59
        except:
61
        except:
60
            pass    
62
            pass    
61
    finally:    
63
    finally:    
62
        driver.quit()
64
        driver.quit()
63
    
65
    
-
 
66
def voiCookies():
64
    
67
    try:
-
 
68
        driver = webdriver.PhantomJS('/usr/local/bin/phantomjs')
-
 
69
        driver.set_window_size(1124, 850) # set browser size.
-
 
70
        driver.get("http://sellers.snapdeal.com")
-
 
71
        driver.maximize_window()
-
 
72
        element = driver.find_element_by_name("pgLogin:navbar:txtUserName")
-
 
73
        element.send_keys(VOI_USER_NAME)
-
 
74
        element = driver.find_element_by_name("pgLogin:navbar:txtPassword")
-
 
75
        element.send_keys(VOI_PASSWORD)
-
 
76
        
-
 
77
        element = driver.find_element_by_name("pgLogin:navbar:j_id11")
-
 
78
        element.click()
-
 
79
        time.sleep(20)
-
 
80
        driver.get("http://seller.snapdeal.com/inventory")
-
 
81
        cookies =  driver.get_cookies()
-
 
82
        print cookies
-
 
83
        try:
-
 
84
            for cookie in cookies:
-
 
85
                if cookie.get('name') == "SERVERID":
-
 
86
                    SERVERID = cookie.get('value')
-
 
87
                if cookie.get('name') == "sfJSESSIONID":
-
 
88
                    sfJSESSIONID = cookie.get('value')
-
 
89
            print SERVERID
-
 
90
            print sfJSESSIONID
-
 
91
            get_mongo_connection(host=options.mongoHost).Snapdeal.VoiCookies.update({"_id":1},{"$set":{"SERVERID":SERVERID,"sfJSESSIONID":sfJSESSIONID}},multi=False,upsert=True)
-
 
92
        except:
-
 
93
            pass
-
 
94
    finally:    
-
 
95
        driver.quit()
-
 
96
 
65
 
97
 
66
 
98
 
67
if __name__=='__main__':
99
if __name__=='__main__':
68
    run()
-
 
69
100
    run()
-
 
101
    voiCookies()
-
 
102
70
103