,我會說,我開始很新的Python。我一直在建立一個不和諧的機器人與discord.py和美麗的湯4,這裏就是我在:在BS4使用find_all獲得文本列表
@commands.command(hidden=True)
async def roster(self):
"""Gets a list of CD's members"""
url = "http://www.clandestine.pw/roster.html"
async with aiohttp.get(url) as response:
soupObject = BeautifulSoup(await response.text(), "html.parser")
try:
text = soupObject.find_all("font", attrs={'size': '4'})
await self.bot.say(text)
except:
await self.bot.say("Not found!")
現在,我已經在使用get_text()
嘗試多種不同的方式來剝離括號和HTML標記從該代碼,但它每次引發錯誤。我將如何能夠既實現這一目標或輸出這個數據到一個數組或列表,然後只打印純文本?
您使用的是哪一種Python和美麗的湯的版本?我假設它是> = python 3.5給定異步等待語法 –