如何让 Python 只读网站的特定部分

How Can I Make Python Read Only a Certain Part Off A Site

@bot.command()
async def id2r(ctx, id):
   response = requests.get(f'https://verify.eryn.io/api/user/{id}')
   
   id2r = discord.Embed(
       title='***Discord ID Scan ↴***', color=16, description=f'{response.text}')
   id2r.timestamp = datetime.now()
   await ctx.send(embed=id2r)

我希望它只打印 robloxUsername 而不是打印站点给出的完整输出。

这称为 json 格式,通常 api 结果使用它。

.json() 使其成为 Json 而不是原始文本。

然后这样称呼它response['robloxUsername']

@bot.command()
async def id2r(ctx, id):
    response = requests.get(f'https://verify.eryn.io/api/user/{id}').json()

    id2r = discord.Embed(
        title='***Discord ID Scan ↴***', color=16, description=response["robloxUsername"])
    id2r.timestamp = datetime.now()
    await ctx.send(embed=id2r)

P.S:我建议使用状态,因为如果 id 错误,则所需字段将不存在。