Answer the question
In order to leave comments, you need to log in
How to "unstick" words in nested tags?
The essence of the question is in the title.
Code:
html = '<span itemprop="text">Lorem ipsum dolor sit amet <a href="">consectetur adipiscing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>'
soup = BeautifulSoup(html)
result = soup.find("span",itemprop="text")
# Результат: "ametconsectetur adipiscing" ссылка приклеилась. Как поставить пробел?
# Lorem ipsum dolor sit ametconsectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Answer the question
In order to leave comments, you need to log in
Maybe I didn't understand something. But everything seems to be ok.
soup = bs4(html,'lxml')
res = soup.find('span')
res.text
'Lorem ipsum dolor sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. '
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question