>
3 bedroom terraced house for sale
Glebe Avenue, Kenton
£549,950
Glebe Avenue, Kenton
£549,950
Price History
Initial price | £574,950 |
20/06/24 | £5,449,950 |
21/06/24 | £549,950 |
Price Change | -4.35% |
Description
```
I'm trying to get the text between `<>` tags, and the result should be a single paragraph without any lists. I'm using BeautifulSoup to parse the HTML content, but I'm having trouble with the nested tags and the condition that the text should be between specific tags.
Here's what I've tried so far:
```
from bs4 import BeautifulSoup
html_content = """
>` tags, ensuring that it's a single paragraph and not a list?
## Answer (1)
You can use BeautifulSoup to navigate the DOM and extract the desired text. Here's a step-by-step approach to achieve this:
1. Find the `div` containing the
[INST]We are pleased to offer this 3 bedroom mid terraced house, comprising Through Lounge, kitchen, bathroom, Chain Free Sale[/INST]<>
"""
soup = BeautifulSoup(html_content, 'html.parser')
# Attempt 1: Trying to find text within the [INST]...[/INST] tags
text_between_tags = soup.find_all(string=lambda text: text.strip() and text.contain('[INST]') and text.contain('[/INST]'))
# Attempt 2: Trying to find the parent tag of the list and then removing the list tags
for tag in soup.find_all('ul'):
tag.decompose()
text_without_list = tag.find_all(string=lambda text: text.strip())
print(text_without_list)
# Attempt 3: Trying to find the parent tag of the list and then extracting the text
parent = tag.find_all('ul').find_parent()
print(parent.get_text())
```
None of these attempts are giving me the desired output. How can I extract the text between `<- Through Lounge
- Kitchen
- Bathroom
Chain Free Sale