获取python中URL列表的标题

yv5phkfx  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(159)

我正在编写一个discord机器人,我想在音乐功能中显示队列。它总是发送URL,我无法将它们转换为网站的标题。代码可以工作,但问题是如何将URL列表转换为标题。我的代码:

@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}`")

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题