Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Commit

Permalink
Fix webap https problem (#70)
Browse files Browse the repository at this point in the history
@abc873693 Thanks for review.
  • Loading branch information
takidog authored and vn7n24fzkq committed May 17, 2019
1 parent 3b5e8f3 commit cc0f15c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/kuas_api/kuas/ap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#-*- encoding=utf-8 -*-
# -*- encoding=utf-8 -*-
"""This module `ap` provide manipulate of kuas AP system.
"""

Expand All @@ -8,7 +8,7 @@
from lxml import etree
# AP URL Setting
#: AP sytem base url
AP_BASE_URL = "http://webap.nkust.edu.tw"
AP_BASE_URL = "https://webap.nkust.edu.tw"

#: AP system login url
AP_LOGIN_URL = AP_BASE_URL + "/nkust/perchk.jsp"
Expand Down Expand Up @@ -109,20 +109,20 @@ def get_semester_list():
login(s, AP_GUEST_ACCOUNT, AP_GUEST_PASSWORD)

content = cache.ap_query(s, "ag304_01")
if len(content)<3000:
if len(content) < 3000:
return False
root = etree.HTML(content)

#options = root.xpath("id('yms_yms')/option")
try:
options = map(lambda x: {"value": x.values()[0].replace("#", ","),
"selected": 1 if "selected" in x.values() else 0,
"text": x.text},
root.xpath("id('yms_yms')/option")
)
"selected": 1 if "selected" in x.values() else 0,
"text": x.text},
root.xpath("id('yms_yms')/option")
)
except:
return False

options = list(options)

return options
Expand Down Expand Up @@ -187,5 +187,5 @@ def query(session, qid, args={}):

if __name__ == "__main__":
#import doctest
#doctest.testmod()
print(get_semester_list())
# doctest.testmod()
print(get_semester_list())
1 change: 1 addition & 0 deletions src/kuas_api/modules/stateless_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def set_cookies(s, username):

def get_requests_session_with_cookies():
s = requests.Session()
s.verify = False

if g.username:
set_cookies(s, g.username)
Expand Down

0 comments on commit cc0f15c

Please sign in to comment.