| 15589 |
kshitij.so |
1 |
from selenium import webdriver
|
|
|
2 |
from selenium.webdriver.common.keys import Keys
|
|
|
3 |
import time
|
|
|
4 |
from dtr.utils.utils import get_mongo_connection
|
|
|
5 |
import optparse
|
|
|
6 |
|
|
|
7 |
USER_NAME = "saholic-snapdeal@saholic.com"
|
|
|
8 |
PASSWORD = "snapsaholic15"
|
| 15596 |
kshitij.so |
9 |
VOI_USER_NAME = "spiceonlineretailvoi@gmail.com"
|
|
|
10 |
VOI_PASSWORD = "saholicsnapdeal1"
|
| 15589 |
kshitij.so |
11 |
|
|
|
12 |
parser = optparse.OptionParser()
|
|
|
13 |
parser.add_option("-m", "--m", dest="mongoHost",
|
|
|
14 |
default="localhost",
|
|
|
15 |
type="string", help="The HOST where the mongo server is running",
|
|
|
16 |
metavar="mongo_host")
|
|
|
17 |
|
|
|
18 |
(options, args) = parser.parse_args()
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
def run():
|
|
|
22 |
try:
|
|
|
23 |
driver = webdriver.PhantomJS('/usr/local/bin/phantomjs')
|
|
|
24 |
driver.set_window_size(1124, 850) # set browser size.
|
|
|
25 |
driver.get("http://sellers.snapdeal.com")
|
|
|
26 |
driver.maximize_window()
|
|
|
27 |
element = driver.find_element_by_name("pgLogin:navbar:txtUserName")
|
|
|
28 |
element.send_keys(USER_NAME)
|
|
|
29 |
element = driver.find_element_by_name("pgLogin:navbar:txtPassword")
|
|
|
30 |
element.send_keys(PASSWORD)
|
|
|
31 |
|
| 15766 |
kshitij.so |
32 |
element = driver.find_element_by_name("pgLogin:navbar:j_id12")
|
| 15589 |
kshitij.so |
33 |
element.click()
|
|
|
34 |
time.sleep(20)
|
|
|
35 |
driver.get("http://seller.snapdeal.com/inventory")
|
|
|
36 |
cookies = driver.get_cookies()
|
|
|
37 |
print cookies
|
|
|
38 |
try:
|
|
|
39 |
for cookie in cookies:
|
|
|
40 |
if cookie.get('name') == "SERVERID":
|
|
|
41 |
SERVERID = cookie.get('value')
|
|
|
42 |
if cookie.get('name') == "sfJSESSIONID":
|
|
|
43 |
sfJSESSIONID = cookie.get('value')
|
|
|
44 |
print SERVERID
|
|
|
45 |
print sfJSESSIONID
|
|
|
46 |
get_mongo_connection(host=options.mongoHost).Snapdeal.Cookies.update({"_id":1},{"$set":{"SERVERID":SERVERID,"sfJSESSIONID":sfJSESSIONID}},multi=False,upsert=True)
|
|
|
47 |
except:
|
|
|
48 |
pass
|
|
|
49 |
driver.get("http://shipping.snapdeal.com/vendor/product-shipment/shippingDashboard")
|
|
|
50 |
time.sleep(10)
|
|
|
51 |
cookies = driver.get_cookies()
|
|
|
52 |
try:
|
|
|
53 |
for cookie in cookies:
|
|
|
54 |
if cookie.get('name') == "AWSELB":
|
|
|
55 |
AWSELB = cookie.get('value')
|
|
|
56 |
if cookie.get('name') == "JSESSIONID":
|
|
|
57 |
JSESSIONID = cookie.get('value')
|
|
|
58 |
print JSESSIONID
|
|
|
59 |
print AWSELB
|
|
|
60 |
get_mongo_connection(host=options.mongoHost).Snapdeal.Cookies.update({"_id":1},{"$set":{"JSESSIONID":JSESSIONID,"AWSELB":AWSELB}},multi=False,upsert=True)
|
|
|
61 |
except:
|
|
|
62 |
pass
|
|
|
63 |
finally:
|
|
|
64 |
driver.quit()
|
|
|
65 |
|
| 15596 |
kshitij.so |
66 |
def voiCookies():
|
|
|
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 |
|
| 15766 |
kshitij.so |
77 |
element = driver.find_element_by_name("pgLogin:navbar:j_id12")
|
| 15596 |
kshitij.so |
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()
|
| 15589 |
kshitij.so |
96 |
|
|
|
97 |
|
| 15596 |
kshitij.so |
98 |
|
| 15589 |
kshitij.so |
99 |
if __name__=='__main__':
|
| 15596 |
kshitij.so |
100 |
run()
|
|
|
101 |
voiCookies()
|