【发布时间】:2020-11-30 21:55:05
【问题描述】:
我正在使用 discord.py 重写和 aiohttp。这个 API 的文档很少,据我所见,我在响应中的任何地方都没有看到“next_page”链接。
我该如何做到,以便在执行查询时考虑 json 响应的所有页面,而不仅仅是默认的第一页?
这是我当前的相关代码:
async def command(ctx, *, name):
if not name:
return await ctx.channel.send('Uhhhh. How am I supposed to show you info if you don\'t enter a name?')
async with ctx.channel.typing():
async with aiohttp.ClientSession() as cs:
async with cs.get("https://website.items.json") as r:
data = await r.json()
listings = data["items"]
for k in listings:
if name.lower() == k["name"].lower():
await ctx.channel.send("message with results and player info as ascertained in the above code")```
【问题讨论】:
标签: python python-3.x pagination discord.py aiohttp