當前位置: 首頁>>代碼示例>>Python>>正文


Python Spider.parse_failed_grade方法代碼示例

本文整理匯總了Python中spider.Spider.parse_failed_grade方法的典型用法代碼示例。如果您正苦於以下問題:Python Spider.parse_failed_grade方法的具體用法?Python Spider.parse_failed_grade怎麽用?Python Spider.parse_failed_grade使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在spider.Spider的用法示例。


在下文中一共展示了Spider.parse_failed_grade方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get

# 需要導入模塊: from spider import Spider [as 別名]
# 或者: from spider.Spider import parse_failed_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"))
開發者ID:qiu0130,項目名稱:usthAPI,代碼行數:56,代碼來源:handler.py


注:本文中的spider.Spider.parse_failed_grade方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。