1. 限制异常信息返回数量

2. 完善52PT签到
This commit is contained in:
ngfchl
2022-11-02 12:52:19 +08:00
parent a9c9dc5c4a
commit 6ff69cba6b
2 changed files with 67 additions and 81 deletions

View File

@@ -177,7 +177,7 @@ class PtSpider:
})
logger.info('爱语飞飞通知:{}'.format(res))
except Exception as e:
logger.info('通知发送失败,{} {}'.format(res, traceback.format_exc()))
logger.info('通知发送失败,{} {}'.format(res, traceback.format_exc(limit=3)))
def send_request(self,
my_site: MySite,
@@ -252,7 +252,7 @@ class PtSpider:
data=imagestring,
)
except Exception as e:
msg = '百度OCR识别失败{}'.format(traceback.format_exc())
msg = '百度OCR识别失败{}'.format(traceback.format_exc(limit=3))
logger.info(msg)
# raise
self.send_text(msg)
@@ -290,8 +290,8 @@ class PtSpider:
except Exception as e:
# raise
# 打印异常详细信息
logger.error(traceback.format_exc())
return CommonResponse.error(msg='Cookies解析失败请确认导入了正确的cookies备份文件{}'.format(traceback.format_exc()))
logger.error(traceback.format_exc(limit=3))
return CommonResponse.error(msg='Cookies解析失败请确认导入了正确的cookies备份文件{}'.format(traceback.format_exc(limit=3)))
# @transaction.atomic
def get_uid_and_passkey(self, cookie: dict):
@@ -379,7 +379,7 @@ class PtSpider:
logger.info('数据导入结果True为新建false为更新')
logger.info(res_status)
except Exception as e:
msg = '{}{} 数据导入出错,错误原因:{}'.format(site.name, key, traceback.format_exc())
msg = '{}{} 数据导入出错,错误原因:{}'.format(site.name, key, traceback.format_exc(limit=3))
logger.info(msg)
continue
if not passkey:
@@ -414,9 +414,9 @@ class PtSpider:
torrent = tr_client.get_torrents(ids=torrent_info.hash_string)
except Exception as e:
# 打印异常详细信息
logger.error(traceback.format_exc())
logger.error(traceback.format_exc(limit=3))
return CommonResponse.error(
msg='下载无法连接,请检查下载器是否正常?!{}'.format(traceback.format_exc())
msg='下载无法连接,请检查下载器是否正常?!{}'.format(traceback.format_exc(limit=3))
)
elif downloader.category == DownloaderCategory.qBittorrent:
try:
@@ -432,9 +432,9 @@ class PtSpider:
torrent = qb_client.torrents_info(hashes=torrent_info.hash_string)
except Exception as e:
# 打印异常详细信息
logger.error(traceback.format_exc())
logger.error(traceback.format_exc(limit=3))
return CommonResponse.error(
msg='下载无法连接,请检查下载器是否正常?{}'.format(traceback.format_exc())
msg='下载无法连接,请检查下载器是否正常?{}'.format(traceback.format_exc(limit=3))
)
# if downloader.category == DownloaderCategory.qBittorrent:
# pass
@@ -470,50 +470,40 @@ class PtSpider:
my_site=my_site,
url=url,
)
sign_str = self.parse(result, '//a[@id="game"]//text()')
logger.info(sign_str)
if len(sign_str) < 1:
return CommonResponse.success(msg='已签到!')
if len(sign_str) >= 1:
return CommonResponse.success(msg='52PT 签到太复杂不支持,访问网站保持活跃成功!')
# questionid = self.parse(result, 'questionid')
# choices = self.parse(result, '//input[contains(@name, "choice[]")]/@value')
msg = self.parse(result, '//font[contains(text(),"签到")]/text()')
return CommonResponse.success(msg='已签到!{}'.format(msg))
# if len(sign_str) >= 1:
# return CommonResponse.success(msg='52PT 签到太复杂不支持,访问网站保持活跃成功!')
questionid = self.parse(result, '//input[contains(@name, "questionid")]/@value')
choices = self.parse(result, '//input[contains(@name, "choice[]")]/@value')
# for choice in choices:
# logger.info(choice)
# submit = {
# 'submit': 'submit'
# }
# while True:
# sign_res = self.send_request(
# my_site=my_site,
# url=site.url + site.page_sign_in.lstrip('/'),
# method=site.sign_in_method,
# data={
# 'questionid': questionid,
# 'choice': choices[random.randint(0, len(choices) - 1)],
# 'usercomment': '十步杀一人,千里不流行!',
# }.update(submit)
# ).content.decode('utf8')
# questionid = self.parse(result, 'questionid')
# choices = self.parse(result, '//input[contains(@name, "choice[]")]/@value')
# logger.info(sign_res)
# if '签到赚魔力' in sign_res:
# submit = {
# 'submit': 'wantskip'
# }
# else:
# return CommonResponse.success(
# msg='签到成功!'
# )
# return CommonResponse.error(
# msg='签到shibai!'
# )
# if isinstance(sign_res, int):
# msg = '你还需要继续努力哦!此次签到,你获得了魔力奖励:{}'.format(sign_res)
# else:
# msg = sign_res
# logger.info(msg)
# logger.info(choice)
data = {
'questionid': questionid,
'choice[]': choices[random.randint(0, len(choices) - 1)],
'usercomment': '十步杀一人,千里不流行!',
'wantskip': '不会'
}
logger.info(data)
sign_res = self.send_request(
my_site=my_site,
url=site.url + site.page_sign_in.lstrip('/'),
method=site.sign_in_method,
data=data
).content.decode('utf8')
logger.info(sign_res)
if '签到赚魔力' in sign_res:
return CommonResponse.error(
msg='签到失败!'
)
else:
msg = self.parse(sign_res, '//font[contains(text(),"签到")]/text()')
return CommonResponse.success(
msg='签到成功!{}'.format(msg)
)
def sign_in_hdupt(self, my_site: MySite):
site = my_site.site
@@ -761,10 +751,10 @@ class PtSpider:
)
except Exception as e:
# 打印异常详细信息
logger.error(traceback.format_exc())
logger.error(traceback.format_exc(limit=3))
return CommonResponse.success(
status=StatusCodeEnum.WEB_CONNECT_ERR,
msg='{}: {}'.format(site.name, traceback.format_exc())
msg='{}: {}'.format(site.name, traceback.format_exc(limit=3))
)
@staticmethod
@@ -1073,7 +1063,7 @@ class PtSpider:
else:
return CommonResponse.error(msg='请确认签到是否成功??网页返回码:' + str(res.status_code))
except Exception as e:
msg = '{}签到失败!原因:{}'.format(site.name, traceback.format_exc())
msg = '{}签到失败!原因:{}'.format(site.name, traceback.format_exc(limit=3))
logger.info(msg)
# raise
# self.send_text(msg)
@@ -1098,7 +1088,7 @@ class PtSpider:
return CommonResponse.error(msg="网站访问失败")
except Exception as e:
# raise
msg = '{} 网站访问失败!原因:{}'.format(site.name, traceback.format_exc())
msg = '{} 网站访问失败!原因:{}'.format(site.name, traceback.format_exc(limit=3))
# 打印异常详细信息
logger.error(msg)
self.send_text(msg)
@@ -1300,7 +1290,7 @@ class PtSpider:
except Exception as e:
# raise
# self.send_text(site.name + '解析种子信息:失败!原因:' + str(e))
msg = '解析种子页面失败!{}'.format(traceback.format_exc())
msg = '解析种子页面失败!{}'.format(traceback.format_exc(limit=3))
logger.error(msg)
return CommonResponse.error(msg=msg)
@@ -1387,7 +1377,7 @@ class PtSpider:
status=StatusCodeEnum.WEB_CONNECT_ERR,
msg='网站访问超时,请检查网站是否维护??')
except Exception as e:
message = '{} 访问个人主页信息:失败!原因:{}'.format(my_site.site.name, traceback.format_exc())
message = '{} 访问个人主页信息:失败!原因:{}'.format(my_site.site.name, traceback.format_exc(limit=3))
logger.error(message)
# self.send_text(message)
# raise
@@ -1615,7 +1605,7 @@ class PtSpider:
return CommonResponse.success(data=result)
except Exception as e:
# 打印异常详细信息
message = '{} 解析个人主页信息:失败!原因:{}'.format(my_site.site.name, traceback.format_exc())
message = '{} 解析个人主页信息:失败!原因:{}'.format(my_site.site.name, traceback.format_exc(limit=3))
logger.error(message)
# raise
# self.send_text('# <font color="red">' + message + '</font> \n')
@@ -1664,7 +1654,7 @@ class PtSpider:
)
except Exception as e:
# 打印异常详细信息
message = '时魔获取失败!{}'.format(traceback.format_exc())
message = '时魔获取失败!{}'.format(traceback.format_exc(limit=3))
logger.error(site.name + message)
return CommonResponse.success(
msg=message,

View File

@@ -23,36 +23,32 @@
<p></p>
<p></p>
<center>
<textarea name="message" style="width: 60%;height: 60px"></textarea>
<p></p>
<div id="showup">
<div id="showup">
<table class="captcha">
<tbody>
<tr>
<td><img
src=""
alt="captcha"
onclick="ajax.update('image.php?action=reload_adbc2&amp;div=showup&amp;rand=2831326998','showup')"
style="cursor: pointer;"></td>
<td><input type="hidden" name="req"
value="a09835abd49e30b69effd72c1a7cb682dad6a976d8317f7473a6a2447a412f86fef5e4e326a38fc55e87efa7a585ed3b5095a8d4ded333e6ca7b7906b594f3b26fac4ae6f78c7934800d5ce565353430"><input
type="hidden" name="hash" value="09c78cfcd73043ddf0f6fc3a4aec266bb4d07d48"><input
type="hidden" name="form" value="586400afd6979bc7aabb92a9d617cfad0c2f6655">
<h3>CAPTCHA</h3>
<input type="submit" name="captcha_0f111ca5f714aac2fc4e8e485df2a0cccda35ef1"
value="Vampiyan Kids / バンパイヤン・キッズ"><br>
<input type="submit" name="captcha_3dd78242da7aa0cd0a12e32cc9b584bd0c049797"
value="Brain Powerd / ブレンパワード"><br>
<input type="submit" name="captcha_b324546cfe38ca2bf89af8312107c754efacd3ec"
value="Karakai Jouzu no Takagi-san 3 / からかい上手の高木さん3 / Teasing Master Takagi-san 3 / 擅长捉弄的高木同学3"><br>
<input type="submit" name="captcha_b1ce8cee3f580362b3646d752fa77b4a5e3a0789"
value="Utawarerumono: Itsuwari no Kamen / うたわれるもの 偽りの仮面 / Utawarerumono: The False Faces / 受讚頌者 虛偽的假面 / 传颂之物 虚伪的假面"><br>
<p>请找出左侧图片中圆点,再选择该处对应的作品名称。<br>注意:本测试有效期 120 秒,请于图片注明的时间前提交。<br><a href="javascript:;"
class="faqlink"
onclick="ajax.update('image.php?action=reload_adbc2&amp;div=showup&amp;rand=2831326998','showup')">刷新</a>
</p>
<td class="text" align="left" width="100%">1、[老手级][单选] 请问什么是H&amp;R</td>
</tr>
<tr>
<td class="text" style="white-space: nowrap;" align="left" width="100%">
<input type="hidden" name="questionid" value="2"/>
<input type='radio' name='choice[]' value='4'>不知道是什么鬼<br/>
<input type='radio' name='choice[]' value='1'>
H&amp;R是英文Hit和Run的简称说白了就是让大家不要做吸血鬼PT大忌是吸血。<br/>
<input type='radio' name='choice[]' value='2'>H&amp;R就是高和右边英文缩写<br/>
</td>
</tr>
<tr>
<td class='text' align='left' width='100%'><textarea cols='100%' rows=2 name='usercomment'>此刻心情:无</textarea>
</td>
</tr>
<tr>
<td class="text" align="center" width="100%">
<input type="submit" name="submit" value="提交"/>
<input type="submit" name="wantchange" value="仅可换一题"/>
<input type="submit" name="wantskip" value="不会"/>
</td>
</tr>
</tbody>