【发布时间】:2018-04-18 13:09:31
【问题描述】:
我不明白如何解决它。 我在网上找不到任何东西。
import re
@client.event
async def on_message(message):
if message.content.startswith(prefix + 'getimg'):
from urllib.request import urlopen
website = urlopen('https://nekos.life/api/hug')
html = website.read()
links = re.findall('"((http|ftp)s?://.*?)"', html)
print(links)
await client.send_message(message.channel, 'get')
【问题讨论】:
-
403:forbidden 所以你没有身份验证或访问该站点
-
本站没有注册
-
看起来您可能必须将
SSLContext传递给urlopen才能访问 HTTPS 页面。您应该借此机会重构您的应用程序以改用aiohttp。urllib不是异步库,因此将其与discord.py代码混合可能会导致阻塞,从而使您的程序崩溃。aiohttp是discord.py使用的异步 Web 库,因此它已经在您的计算机上。
标签: python discord discord.py urlopen