How to get text from div using beautifulSoup?

<div class="amount">
1271
</div>

There is such code,you need to get out 1271,but when you run the program:
full_page = requests.get(self.DOLLAR_RUB, headers=self.headers)

# Parse using BeautifulSoup
soup = BeautifulSoup(full_page.content, 'html.parser')

# Get the value and return it
self.convert = soup.findAll("div", {"class": "amount "})
print(self.convert)

displays ""
Why it can't see the text?
April 9th 20 at 10:49
1 answer
April 9th 20 at 10:51
self.convert = soup.find_all(class_="amount")
for entry in self.convert:
 print(entry.get_text())
[]
Traceback (most recent call last):
File "corona.py", line 54, in
currency = Currency()
File "corona.py", line 18, in __init__
self.current_converted_price = int(self.get_currency_price())
File "corona.py", line 33, in get_currency_price
return self.convert[0].text
IndexError: list index out of range - raquel.Ratke commented on April 9th 20 at 10:54
@raquel.RatkeYou another piece of code threw? - Lilla54 commented on April 9th 20 at 10:57
import requests # Module to handle the URL
from bs4 import BeautifulSoup # Module for working with HTML
import time # Module for stopping the program
import smtplib # Module for working with mail

# The main class
class Currency:
# Link to the correct page
DOLLAR_RUB = 'https://coronavirus-monitor.ru/coronavirus-v-rossii/'
# Headers for transmission along with the URL
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'}

current_converted_price = 0
difference = 5 # the Difference after which the message will be sent in the mail

def __init__(self):
# Setting the exchange rate when the object is created
self.current_converted_price = int(self.get_currency_price())
self.current_converted_price1 = int(self.convert[1].text)
self.current_converted_price2= int(self.convert[2].text)

# Method to get the currency rate
def get_currency_price(self):
# Parsim whole page
full_page = requests.get(self.DOLLAR_RUB, headers=self.headers)

# Parse using BeautifulSoup
soup = BeautifulSoup(full_page.content, 'html.parser')

# Get the value and return it
self.convert = soup.find_all(class_="amount")
for entry in self.convert:
print(entry.get_text())
return self.convert[0].text

# Check currency
def check_currency(self):
currency = int(self.convert[0].text)
currency1 = int(self.convert[1].text)
currency2 = int(self.convert[2].text)

print("Now cured:" + str(currency)+"(+"+str(currency-self.current_converted_price)+")")
print("Now patients:" + str(currency1)+"(+"+str(currency1-self.current_converted_price1)+")")
print("Now dead:" + str(currency2)+"(+"+str(currency2-self.current_converted_price2)+")")
print("----------------------------------------------------------------")
#time.sleep(600)
#self.get_currency_price()
#self.check_currency()

# Send mail through SMTP


# The object creation and method invocation
currency = Currency()
currency.check_currency() - raquel.Ratke commented on April 9th 20 at 11:00
@raquel.Ratke, Cycle outputs the data? - Lilla54 commented on April 9th 20 at 11:03
@Lilla54, Yes,sort of - raquel.Ratke commented on April 9th 20 at 11:06
@raquel.Ratke, Then, if you need only first element, so:
self.convert = soup.find(class_="amount")
return self.convert.get_text()
- Lilla54 commented on April 9th 20 at 11:09

Find more questions by tags Beautiful SoupPython