Python discord.py';非类型';对象没有属性';查找';

Python discord.py';非类型';对象没有属性';查找';,python,python-3.x,beautifulsoup,discord,discord.py,Python,Python 3.x,Beautifulsoup,Discord,Discord.py,当我使用命令时!R csgonow我收到以下错误: @client.command() async def csgonow(ctx): url = "https://steamdb.info/app/730/graphs/" async with aiohttp.ClientSession() as session: async with session.get(url) as response: soupObject

当我使用命令
时!R csgonow
我收到以下错误:

@client.command()
async def csgonow(ctx):
    url = "https://steamdb.info/app/730/graphs/" 
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            soupObject = BeautifulSoup(await response.text(), "html.parser")
            online = soupObject.find(class_='home-stats').find('li').find('strong').get_text()
            await ctx.send(online + ' players are playing this game at the moment')

如何修复此问题?

您可以使用CSS选择器:

 discord.ext.commands.errors.CommandInvokeError: Command raised an exception:
  AttributeError: 'NoneType' object has no attribute 'find'

对我来说,这看起来没什么问题,但如果添加一些调试消息来查看发生了什么,这会更容易。例如,将
wait response.text()
保存在变量中并打印该变量。它还将有助于删除不必要的代码。不和,因为你的问题似乎与不和无关。
@client.command()
async def csgonow(ctx):
    url = "https://steamdb.info/app/730/graphs/"
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            soupObject = BeautifulSoup(await response.text(), "html.parser")
            online = soupObject.select_one('.app-chart-numbers-big > li:nth-child(2) > strong:nth-child(1)').text
            await ctx.send(f' {online} players are playing this game at the moment')