本文整理匯總了Python中spider.Spider.parse_semester_grade方法的典型用法代碼示例。如果您正苦於以下問題:Python Spider.parse_semester_grade方法的具體用法?Python Spider.parse_semester_grade怎麽用?Python Spider.parse_semester_grade使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類spider.Spider
的用法示例。
在下文中一共展示了Spider.parse_semester_grade方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from spider import Spider [as 別名]
# 或者: from spider.Spider import parse_semester_grade [as 別名]
def get(self, *args, **kwargs):
query = self.get_argument("query")
student_number = self.get_argument("stu_no")
password = self.get_argument("pwd")
spider = Spider(student_number=student_number, password=password)
spider.authorized()
student_id = spider.student_id
self.set_header("Content-Type", "application/json")
try:
if query == "semester":
storage = self.redis_cls.get_semester_grade(student_id)
if storage is None:
current = spider.parse_semester_grade()
if current.code != 0:
self.write(json.dumps(dict(current._asdict())))
return
data = current.data
else:
data = storage
elif query == "pass":
storage = self.redis_cls.get_passed_grade(student_id)
if storage is None:
current = spider.parse_passed_grade()
if current.code != 0:
self.write(json.dumps(dict(current._asdict())))
return
data = current.data
else:
data = storage
elif query == "fail":
storage = self.redis_cls.get_failed_grade(student_id)
if storage is None:
current = spider.parse_failed_grade()
if current.code != 0:
self.write(json.dumps(dict(current._asdict())))
return
data = current.data
else:
data = storage
else:
raise ValueError("Query Operation Out")
self.write(gen_response(code=0x0000,
data=data,
msg="成功",
en_msg="Success"))
except Exception as err:
self.write(gen_response(code=0x0001,
msg=str(err),
en_msg="Unknown Error"))