Skip to content

Commit f411fe5

Browse files
committed
新增一个回帖异常处理
遇到502错误时重试
1 parent b7bd054 commit f411fe5

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
### 更新日志
66

77
```
8+
2023.10.24-Based-0.23.10.24.1
9+
从上游仓库同步更新,Commit:“新增一个回帖异常处理 (#31)”
10+
发帖遇到502错误时重试
11+
812
2023.09.13-Based-0.23.09.07.1
9-
smtp模块新增 开启 / 关闭 SSL选项
13+
基于smtp的日志投递模块新增 开启 / 关闭 SSL选项
1014
1115
2023.09.07-Based-0.23.09.07.1
1216
从上游仓库同步更新,Commit:“修正一处文本描述的错误 (#30)”

index.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
DEBUG = False
1515

16-
__verison__ = "2023.09.13-Based-0.23.09.07.1"
16+
__verison__ = "2023.10.24-Based-0.23.10.24.1"
1717

1818
def outputLog(projectName):
1919
log = logging.getLogger(f"{projectName}")
@@ -96,13 +96,12 @@ def deco(*args , **kargs):
9696
return deco
9797

9898
def save_cookies(session : requests.Session , filename : str) -> None:
99-
...
100-
# with open(filename, 'wb') as f:
101-
# try:
102-
# pickle.dump(session.cookies, f)
103-
# log.debug(f"save {filename} success")
104-
# except:
105-
# ...
99+
try:
100+
with open(filename, 'wb') as f:
101+
pickle.dump(session.cookies, f)
102+
log.debug(f"save {filename} success")
103+
except:
104+
...
106105

107106
def load_cookies(session : requests.Session , filename : str) -> None:
108107
with open(filename, 'rb') as f:
@@ -348,6 +347,9 @@ def reply(self, url) -> bool:
348347
elif res.text.find("該貼已被鎖定") != -1:
349348
log.info(f"{self.username} reply failed , the thread is locked")
350349
return True
350+
elif res.text.find("502 Bad Gateway") != -1:
351+
log.info(f"{self.username} reply failed , HTTP 502 Error")
352+
return True
351353
else:
352354
log.error(f"{self.username} reply {url} failed , unknown error")
353355
log.error(res.text)

0 commit comments

Comments
 (0)