Вы можете получить к нему доступ, используя свойство contents
.
import requests
from bs4 import BeautifulSoup
URL = 'https://www.health.nsw.gov.au/news/Pages/20200329_01.aspx'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
results = soup.find('td', class_='moh-rteTableFooterOddCol-6')
if results and results.contents :
print(int(results.contents[0].replace(',','')))
В будущем, когда вы не знаете свойств возвращаемого объекта, используйте __dict__
для декодирования объекта.
В качестве примера
>> results.__dict__
{'attrs': {'class': ['moh-rteTableFooterOddCol-6']},
'can_be_empty_element': False,
'cdata_list_attributes': {'*': ['class', 'accesskey', 'dropzone'],
'a': ['rel', 'rev'],
'area': ['rel'],
'form': ['accept-charset'],
'icon': ['sizes'],
'iframe': ['sandbox'],
'link': ['rel', 'rev'],
'object': ['archive'],
'output': ['for'],
'td': ['headers'],
'th': ['headers']},
'contents': ['93,099'],
'hidden': False,
'known_xml': False,
'name': 'td',
'namespace': None,
'next_element': '93,099',
'next_sibling': None,
'parent': <tr class="moh-rteTableFooterRow-6"><td class="moh-rteTableFooterEvenCol-6">Total</td>
<td class="moh-rteTableFooterOddCol-6">93,099</td></tr>,
'parser_class': bs4.BeautifulSoup,
'prefix': None,
'preserve_whitespace_tags': {'pre', 'textarea'},
'previous_element': '\n',
'previous_sibling': '\n',
'sourceline': 1075,
'sourcepos': 0}