【问题标题】:Discord Python Rewreite - Channel SearcherDiscord Python Rewreite - 频道搜索器
【发布时间】:2020-10-29 17:17:39
【问题描述】:

所以,我正在尝试进行 YouTube 频道搜索,我制作了一个简单的代码,但它不起作用,它总是发送 https://www.youtube.com/channel/v=XIDzSr3oX1w%22,%22webPageT,(不是有效链接), 代码是

@client.command()
async def channel(ctx, *, search):

    query_string = urllib.parse.urlencode({
        'search_query': search
        })
    htm_content = urllib.request.urlopen(
        'https://www.youtube.com/results?' + query_string
        )
    search_results = re.findall(r'/watch\?v=(.{24})', htm_content.read().decode())
    await ctx.send('https://www.youtube.com/channel/' + search_results[0])

【问题讨论】:

    标签: discord discord.py discord.py-rewrite


    【解决方案1】:

    您无法解析 youtube 中的搜索结果。 Youtube 是一个动态生成的网站。如果您想真正解析 youtube,您可能需要使用 youtube API 或使用 python selenium

    【讨论】:

      猜你喜欢
      • 2021-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 2019-03-25
      • 2021-01-05
      • 2020-04-18
      相关资源
      最近更新 更多