python - 在 Python 中获取 url 列表的标题
问题描述
我正在编写一个 Discord Bot,我想在音乐功能中显示队列。它总是发送网址,我无法将它们转换为网站的标题。该代码有效,但问题是如何将网址列表转换为标题。我的代码:
@client.command()
async def view(ctx):
global queue
#convert url to title
html = request.urlopen(queue[0]).read().decode('utf8')
html[:60]
soup = BeautifulSoup(html, 'html.parser')
title= soup.find('title')
await ctx.send(f":page_facing_up: ・ Your queue: `{queue}`")
解决方案
推荐阅读
- reactjs - 跨多个编辑器共享 Draft.js 工具栏?
- c++ - 如何减少安装 R 库的 Docker 容器的构建时间?
- python - 如何在 YOLO 对象检测中填充/模糊边界框的内部?
- java - 在 java/scala 中使用一种格式化程序处理各种时间戳?
- python - Python异步函数永远不会被等待
- ios - 最终用户是否可以使用模拟位置应用程序来模拟 iOS 应用程序中的用户位置?
- jmeter - 如何在 Jmeter 中使用非 GUI 模式创建 8 个实例,每个实例有 500 个用户
- telegram - pyTelegramBotAPI 消息处理程序看不到照片
- yolo - 使用 vitisai 在 FPGA 上加速 yolov4-tiny 自己的架构
- laravel - Socket.io 重定向到 cPanel 上的 public/socket.io - 301