嗨,我看过其他几个论坛,但根据他们的代码无法诊断我的问题。这是针对不和谐的bot的,每当我收到此错误时,它都会强制退出代码。我每次跑步都不会发生这种情况,而且我也无法弄清楚为什么或如何预防它。 这是我的代码如下:
@client.event
async def on_message(message):
if message.content.startswith('!view'):
old = message.content
url = old.replace("!view", "").strip()
print ("Viewer started")
headers1 = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
}
for i in range(100):
try:
r = requests.get(url,headers=headers1,verify=False,timeout=5)
if r.status_code == 99:
print("Viewed successfully")
loop = asyncio.get_event_loop()
loop.close()
except Exception as e:
print(e)
非常感谢您,我真的很困惑!