F
F
Fox7772020-04-15 00:13:31
Python
Fox777, 2020-04-15 00:13:31

When parsing everything fit without spaces?

import requests
from bs4 import BeautifulSoup

url = ' https://koronavirusa.site/en '
page = requests.get(url)
soup = BeautifulSoup(page.text, "html.parser")
news = soup.find('div' , class_='sppb-container-inner')
print(news.getText())

problem:
1,990,097INFECTED125,859DIED466,948ALL RECOVERED

without spaces, how can they be separated?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-04-15
@Fox7777

import requests
from bs4 import BeautifulSoup

url = 'https://koronavirusa.site/ru'
page = requests.get(url)
soup = BeautifulSoup(page.text, "html.parser")
container = soup.find('div', class_='sppb-container-inner')
data = container.find_all('div',class_='sppb-animated-number')

infected = data[0].text
died = data[1].text
healed = data[2].text

print(f'''Заражено: {infected}
Умерло: {died}
Выздоровело: {healed}''')

Заражено: 1,990,746
Умерло: 125,919
Выздоровело: 466,997

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question