Answer the question
In order to leave comments, you need to log in
How to parse here?
BS4 does not help, swears at the encoding of the parsed data, I decided to parse the site completely with selenium
There is html code
<body>
<div>
<tr>Содержимое тэга 1</tr>
<tr>Содержимое тэга 2</tr>
<tr>Содержимое тэга 3</tr>
<tr>Содержимое тэга 4</tr>
</div>
</body>
f"<div class='cl'>{переменная в которой лежит Содержимое тэга 1}</div>"
<div class="cl">Содержимое тэга 1</div>
<div class="cl">Содержимое тэга 2</div>
<div class="cl">Содержимое тэга 3</div>
Answer the question
In order to leave comments, you need to log in
BS4 doesn't help
#!/usr/bin/env python
from bs4 import BeautifulSoup
html = """
<body>
<div>
<tr>Содержимое тэга 1</tr>
<tr>Содержимое тэга 2</tr>
<tr>Содержимое тэга 3</tr>
<tr>Содержимое тэга 4</tr>
</div>
</body>
"""
soup = BeautifulSoup(html, 'html.parser')
res = soup.select('tr')
for item in res:
print(f"<div class='cl'>{item.text.strip()}</div>")
$ ./test.py
<div class='cl'>Содержимое тэга 1</div>
<div class='cl'>Содержимое тэга 2</div>
<div class='cl'>Содержимое тэга 3</div>
<div class='cl'>Содержимое тэга 4</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question