K
K
Konstantin Volkov2021-07-22 19:17:17
Python
Konstantin Volkov, 2021-07-22 19:17:17

How to get text from a site without a class using BeutifulSoup?

Hello. I am a complete beginner in programming, so I immediately apologize if I ask a stupid question. How to parse text from a site where there are no classes, but only a tag?
example:
td>
a href=" https://www.life-moon.pp.ru/moon-days/20/undertakings/ " title="Beginnings on the 20th day of the moon">
b>beginnings are excellent
b>
/b >

td class="c5 hidden-xs">
great
/td>

td class="hidden-xs">
a href=" https://www.life-moon.pp.ru/moon-days/20/undertakings/ ">why?
/td>

td>
a href=" https://www.life-moon.pp.ru/best-days/1/ " title="

From the above HTML, I'm trying to get the words: BEGINNINGS and EXCELLENT. if you set soup.findAll('tr'), then the code takes the entire page. Help me please! Thank you in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
snxx, 2021-07-23
@SvaroG911

sp.find('tr').find_all('td').find('a').text
I think this will help you

D
DTPlayer, 2021-07-22
@DTPlayer

soup.find_all('td')[1:3]
This is looking at your HTML code, it turns out
find_all returns a list, not text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question