Z
Z
zhenyabondarev2020-03-29 11:33:50
Python
zhenyabondarev, 2020-03-29 11:33:50

How to get text from div using beautifulSoup?

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

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

# Разбираем через BeautifulSoup
soup = BeautifulSoup(full_page.content, 'html.parser')

# Получаем нужное для нас значение и возвращаем его
self.convert = soup.findAll("div", {"class": "amount "})
print(self.convert)

outputs ""
Why can't it see the text?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-03-29
@Seasle

self.convert = soup.find_all(class_="amount")
for entry in self.convert:
    print(entry.get_text())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question