Парсинг информации с сайта (числа)
Так как я изучаю Python, то решил от делать нечего написать простенький парсер статистики COVID-19 с одного сайта, но я столкнулся с проблемой, что я не могу спарсить числа(кол-во) Вот ниже мой код:
import requests
from bs4 import BeautifulSoup
def parse():
URL = 'https://coronavirus-monitor.ru/statistika/'
HEADERS = {
'User-Agent': '' #User-Agent у меня есть в коде.
}
response = requests.get(URL, headers = HEADERS)
soup = BeautifulSoup(response.content, 'html.parser')
items = soup.findAll('div', class_ = 'total-table-row')
comps = []
for item in items:
comps.append({
'confirmed': item.find('div', class_ = 'value js-confirmed-value').get_text() #Ошибка тут
})
for comp in comps:
print(comp['confirmed'])
parse()
То, я подчеркнул - я не могу спарсить, а то, что сверху, т.е классы "name violet", "name gray" и "name green" - я могу парсить. В итоге, у меня выводится эта ошибка:
Traceback (most recent call last):
File "c:/Users/User/Desktop/Парсинг/Parser.py", line 27, in <module>
parse()
File "c:/Users/User/Desktop/Парсинг/Parser.py", line 17, in parse
'confirmed': item.find('div', class_ = 'value js-confirmed-value').get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'
