@@ -37,19 +37,37 @@ def signin(self, site_info: dict):
3737 ua = site_info .get ("ua" )
3838 proxy = Config ().get_proxies () if site_info .get ("proxy" ) else None
3939
40+ # 尝试解决瓷器cookie每天签到后过期,只保留hdchina=部分
41+ cookie = ""
42+ # 按照分号进行字符串拆分
43+ sub_strs = site_cookie .split (";" )
44+ # 遍历每个子字符串
45+ for sub_str in sub_strs :
46+ if "hdchina=" in sub_str :
47+ # 如果子字符串包含"hdchina=",则保留该子字符串
48+ cookie += sub_str + ";"
49+
50+ if "hdchina=" not in cookie :
51+ self .error (f"签到失败,cookie失效" )
52+ return False , f'【{ site } 】签到失败,cookie失效'
53+
54+ site_cookie = cookie
4055 # 获取页面html
4156 html_res = RequestUtils (cookies = site_cookie ,
4257 headers = ua ,
4358 proxies = proxy
44- ).get_res (url = "https://hdchina.org/" )
59+ ).get_res (url = "https://hdchina.org/index.php " )
4560 if not html_res or html_res .status_code != 200 :
4661 self .error (f"签到失败,请检查站点连通性" )
4762 return False , f'【{ site } 】签到失败,请检查站点连通性'
4863
49- if "login.php" in html_res .text :
64+ if "login.php" in html_res .text or "阻断页面" in html_res . text :
5065 self .error (f"签到失败,cookie失效" )
5166 return False , f'【{ site } 】签到失败,cookie失效'
5267
68+ # 获取新返回的cookie进行签到
69+ site_cookie = ';' .join (['{}={}' .format (k , v ) for k , v in html_res .cookies .get_dict ().items ()])
70+
5371 # 判断是否已签到
5472 html_res .encoding = "utf-8"
5573 sign_status = self .sign_in_result (html_res = html_res .text ,
0 commit comments