From 3a19a9bd4e301fa7e0d081e9c2aada3ac77700c1 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 26 十二月 2023 18:10:29 +0800 Subject: [PATCH] bug修复 --- third_data/kpl_api.py | 88 +++++++++++++++++++++++++++++++++++++++----- 1 files changed, 78 insertions(+), 10 deletions(-) diff --git a/third_data/kpl_api.py b/third_data/kpl_api.py index 4418b13..3bd6925 100644 --- a/third_data/kpl_api.py +++ b/third_data/kpl_api.py @@ -135,14 +135,82 @@ return None +# 鑾峰彇F10涓殑绮鹃�夋澘鍧� +def __getConceptJXBK(code): + data = f"a=GetConceptJXBKw23&apiv=w32&c=StockF10Basic&StockID={code}&PhoneOSNew=1&DeviceID=a38adabd-99ef-3116-8bb9-6d893c846e23&VerSion=5.8.0.2&" + result = __base_request("https://apparticle.longhuvip.com/w1/api/index.php", data=data, timeout=3) + result = json.loads(result) + if result: + if "List" in result: + names = [x["CName"].replace("姒傚康", "") for x in result["List"]] + return names + return [] + + +# 鑾峰彇F10甯歌鏉垮潡 +def __getConceptBK(code): + data = f"a=GetConceptw23&apiv=w32&c=StockF10Basic&StockID={code}&PhoneOSNew=1&DeviceID=a38adabd-99ef-3116-8bb9-6d893c846e23&VerSion=5.8.0.2&" + result = __base_request("https://apparticle.longhuvip.com/w1/api/index.php", data=data, timeout=3) + result = json.loads(result) + if result: + if "List" in result: + names = [x["CName"].replace("姒傚康", "") for x in result["List"]] + return names + return [] + + +# 鑾峰彇浠g爜鐨勬澘鍧� +def getCodeBlocks(code): + blocks = [] + try: + _bks = __getConceptJXBK(code) + if _bks: + blocks.extend(_bks) + except: + pass + + try: + _bks = __getConceptBK(code) + if _bks: + blocks.extend(_bks) + except: + pass + return list(set(blocks)) + + +# 鑾峰彇F10閲岄潰鐨勫ぇ浜嬩欢 +def __getF10BigReminders(code): + data = f"a=BigReminder&st=25&apiv=w32&c=StockF10Basic&StockID={code}&PhoneOSNew=1&DeviceID=a38adabd-99ef-3116-8bb8-6d893c846e23&VerSion=5.8.0.2&Index=0&" + result = __base_request("https://apparticle.longhuvip.com/w1/api/index.php", data=data, timeout=3) + result = json.loads(result) + if int(result["errcode"]) == 0: + return result["info"] + return None + + +# 鑾峰彇鑲$エ鍑忔寔鏃ユ湡 +def getCodeReductionDate(code): + infos = __getF10BigReminders(code) + if not infos: + return None + keys = ["缁堟", "缁撴潫", "缁撴灉", "涓嶅噺鎸�", "瀹屾垚"] + for info in infos: + if info.get("type") == 5: + title = str(info.get("title")) + if title.find("鍑忔寔") < 0: + continue + wrong = False + for k in keys: + if title.find(k) >= 0: + wrong = True + if wrong: + continue + return info.get("date").split(" ")[0] + return None + + if __name__ == "__main__": - blocks = getCodeJingXuanBlocks("002827") - if len(blocks) > 2: - # 鏍规嵁娑ㄥ箙鎺掑簭 - blocks.sort(key=lambda x: x[2]) - blocks.reverse() - datas = [] - for b in blocks: - if b[2] > 0 and b[1] not in constant.KPL_INVALID_BLOCKS: - datas.append(b) - print(datas) + codes = "000422,000536,000619,000766,000892,001255,001258,001300,002288,002442,002584,002632,002771,002942,300505,300949,600293,600610,600679,600769,603168,603188,603291,603329,603392,603518,603759,603767,603836,603839,603938,605218,688655" + codes = codes.split(",") + for code in codes: + print(code, getCodeReductionDate(code)) -- Gitblit v1.8.0