Closed HMScygnet closed 1 year ago
已确认不是风控问题,我设了一个指令手动清空循环才能正确发送验证码链接
try:
loog = asyncio.get_running_loop()
loop.close()
except:
pass
for i in acinfo:
bclient = bsdkclient(i, captchaVerifier, errlogger)
client = pcrclient(bclient)
loop = asyncio.get_event_loop()
loop.create_task(query(client))
await bot.send(ev,'登陆成功')
好像有这回事,但是我没遇到过,建议先自行修改尝试
看了下源项目,可能是因为这个?cc004/pcrjjc2@222cd5a
试了一下这个并没有用,目前只能靠手动重连先顶着
是不是过码的问题
是不是过码的问题
不是,我是手动过码,清空循环重登才发链接
经测试是由于B站服务端不响应导致的,request的timeou仅针对本地网络异常,可以在pcrclient.py
的class pcrclient
中使用asyncio.wait_for
来检测超时
...
async def request_with_timeout(self,session, url, data, headers, timeout):
try:
response = await session.post(url, data=data, headers=headers)
return await response.content.read()
except asyncio.TimeoutError:
print("请求超时")
return None
async def callapi(self, apiurl: str, request: dict, crypted: bool = True, noerr: bool = False):
key = pcrclient.createkey()
try:
if self.viewer_id is not None:
request['viewer_id'] = b64encode(pcrclient.encrypt(str(self.viewer_id), key)) if crypted else str(self.viewer_id)
url = apiroot + apiurl
data = pcrclient.pack(request, key) if crypted else str(request).encode('utf8')
async with aiohttp.ClientSession() as session:
response = await asyncio.wait_for(
self.request_with_timeout(session, url, data, self.headers, 10),
timeout=10
)
if response is not None:
pass
else:
self.shouldLogin = True
raise
...
你调大timeout是不是效果一样,aiohttp是你自己之前改的?
你调大timeout是不是效果一样,aiohttp是你自己之前改的?
这个问题是由于服务端不响应导致的,与timeout数值无关,服务端不响应就会一直等下去,aiohttp是我自己改的,用hoshino的aiorequests应该也行
你先改回aiorequests试试
aiorequests也行,小改一下
async def request_with_timeout(self,url, data, headers, timeout):
try:
response = await post(url, data=data, headers=headers,timeout=timeout)
return await response.content
except asyncio.TimeoutError:
print("请求超时")
return None
async def callapi(self, apiurl: str, request: dict, crypted: bool = True, noerr: bool = False):
key = pcrclient.createkey()
try:
if self.viewer_id is not None:
request['viewer_id'] = b64encode(pcrclient.encrypt(str(self.viewer_id), key)) if crypted else str(self.viewer_id)
url = apiroot + apiurl
data = pcrclient.pack(request, key) if crypted else str(request).encode('utf8')
response = await asyncio.wait_for(
self.request_with_timeout(url, data, self.headers, 10),
timeout=10
)
if response is not None:
pass
else:
self.shouldLogin = True
raise
查询用号掉线以后不尝试重登,无法使用竞技场功能,只能整个重启