M
M
multiapi2020-08-13 11:36:05
Python
multiapi, 2020-08-13 11:36:05

Beautiful design when parsing?

Good afternoon. There is a code.

@client.command()
async def online(ctx):
    parse = "https://arizona-rp.com"
    headers = {"User-Agent": "?)"}

    page = requests.get(parse, headers = headers)
    soup = BeautifulSoup(page.content, "html.parser")
    serveronline = soup.find("div", "monitoring").text

    embed = discord.Embed(description = 'Мониторинг игровых серверов Arizona', color = random.choice(colors))
    embed.add_field(name = f"`Онлайн серверов`", value = serveronline, inline = False)
                
    await ctx.send(embed = embed)


But the output is not very nice xlKqhKk.png

. Is there any information on how to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-08-13
@multiapi

Try the strip() method:

serveronline = soup.find("div", "monitoring").text.strip()

PS: Most likely it won't work, because you're tricky by choosing everything at once. You need to take a "tablet" of each server and parse data from it in a loop. And then everything will be beautiful, without unnecessary empty lines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question