1212
1313DEBUG = False
1414
15- __verison__ = "0.25.02.22 .1"
15+ __verison__ = "0.25.02.25 .1"
1616
1717def outputLog (projectName ):
1818 log = logging .getLogger (f"{ projectName } " )
@@ -94,6 +94,7 @@ def deco(*args , **kargs):
9494 except IOError :
9595 sleep (3 )
9696 retry_number -= 1
97+ log .error (f"Error: { sys .exc_info ()[0 ]} " )
9798 except Exception as e :
9899 log .error (e )
99100 break
@@ -337,7 +338,10 @@ def reply(self, url) -> bool:
337338 'verify' :'verify' ,
338339 'Submit' : '正在提交回覆..' ,
339340 }
340- res = requests .post (url = self .Post , data = data , headers = self .Headers , cookies = self .cookies , proxies = proxies )
341+ try :res = requests .post (url = self .Post , data = data , headers = self .Headers , cookies = self .cookies , proxies = proxies )
342+ except Exception as e :
343+ log .error (f"{ self .username } reply failed , the reason is: { type (e ).__name__ } " )
344+ return True
341345 if DEBUG : print (res .text )
342346 if res .text .find ("發貼完畢點擊進入主題列表" ) != - 1 :
343347 self .ReplyCount -= 1
@@ -346,9 +350,12 @@ def reply(self, url) -> bool:
346350 elif res .text .find ("灌水預防機制" ) != - 1 :
347351 log .info (f"{ self .username } reply failed , user replay too frequency" )
348352 return True
349- elif res .text .find ("所屬的用戶組 " ) != - 1 :
353+ elif res .text .find ("每日最多能發 " ) != - 1 :
350354 log .info (f"{ self .username } reply failed , day reply times is over" )
351355 return False
356+ elif res .text .find ("請先登錄論壇" ) != - 1 :
357+ log .info (f"{ self .username } reply failed , account not logged in" )
358+ return False
352359 elif res .text .find ("管理員禁言, 類型為永久禁言" ) != - 1 :
353360 log .info (f"{ self .username } reply failed , user is banned" )
354361 return False
@@ -364,16 +371,16 @@ def reply(self, url) -> bool:
364371 elif res .text .find ("標題為空或標題太長" ) != - 1 or res .text .find ("文章長度錯誤" ) != - 1 :
365372 log .info (f"{ self .username } reply failed , the title is { title } , the content is { content } " )
366373 return True
367- elif res .text . find ( "403 Forbidden" ) != - 1 :
374+ elif res .status_code == 403 :
368375 log .info (f"{ self .username } reply failed , HTTP 403 Error , 可能由于触发了风控 , IP被服务器拦截" )
369376 return False
370- elif res .text . find ( "500 Internal Server Error" ) != - 1 :
377+ elif res .status_code == 500 :
371378 log .info (f"{ self .username } reply failed , HTTP 500 Error" )
372379 return True
373- elif res .text . find ( "Bad Gateway" ) != - 1 or res . text . find ( "Bad gateway" ) != - 1 :
380+ elif res .status_code == 502 :
374381 log .info (f"{ self .username } reply failed , HTTP 502 Error" )
375382 return True
376- elif res .text . find ( "520: Web server is returning an unknown error" ) != - 1 :
383+ elif res .status_code == 520 :
377384 log .info (f"{ self .username } reply failed , HTTP 520 Error" )
378385 return True
379386 elif res .text .find ("Cloudflare Ray ID" ) != - 1 :
0 commit comments