Skip to content

Commit 3a23704

Browse files
committed
Get The Right Cookie
1 parent 3ae43e6 commit 3a23704

File tree

3 files changed

+28
-43
lines changed

3 files changed

+28
-43
lines changed

make_celery.pyc

-1.07 KB
Binary file not shown.

monitor.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,39 @@
138138

139139
#信息门户登录 AND 得到Cookie
140140
def login_xinximenhu(i):
141+
#得到 status code
141142
resp01 = requests.get("https://ccnubox.muxixyz.com/api/info/login/",
142143
headers = {"Authorization": "Basic %s" %b64Val})
143144
statu01 = resp01.status_code
144145
r01.set(i,statu01)
146+
147+
#因为这个网站登陆时有三个重定向,所以需要模拟这个过程
148+
#才能得到正确的cookie
149+
info_login_url = "http://portal.ccnu.edu.cn/loginAction.do"
150+
link_url = "http://portal.ccnu.edu.cn/roamingAction.do?appId=XK"
151+
login_ticket_url = "http://122.204.187.6/xtgl/login_tickitLogin.html"
152+
headers = {
153+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
154+
}
155+
156+
post_data = {
157+
'userName': 2016210942,
158+
'userPass': 130395
159+
}
160+
161+
s = requests.Session()
162+
r = s.post(info_login_url,data = post_data,headers=headers)
163+
164+
if r.text.split('"')[1] == 'index_jg.jsp':
145165

146-
#json
147-
json = resp01.json()
148-
cookie = json['cookie']
149-
jwcinfo = str(cookie['BIGipServerpool_jwc_xk'])
150-
jsessionid = str(cookie['JSESSIONID'])
151-
166+
r_second = s.get(link_url,timeout = 4)
167+
r_third = s.get(login_ticket_url,timeout = 4)
168+
ret3 = s.__dict__
169+
cookies = ret3['cookies']
170+
jwcinfo = cookies2['BIGipServerpool_jwc_xk']
171+
jsessionid = cookies2.values()[1]
172+
173+
152174
global login_info_header
153175
login_info_header = {
154176
'Bigipserverpool_Jwc_Xk':jwcinfo,

test/moni2.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)