Question: Some `<p></p>` tags has `<img>` tag and `<h4>` tag, but I want just those `<p>` tag which has no siblings tags in it just contents.

```
 <p> <img src="any url"/> </p>     <p> hello world </p>

```

I want `<p>` tag which has no `<img>` tag using beautiful soup

Answer: 
This will get all the text in `<p>` elements but won't get it from any of the child elements in the `<p>`. Recursive needs to be equal false otherwise it will look into the child elements. I've added in another test case for you to show this: `<p><h4>Heading</h4></p>`

```
from bs4 import BeautifulSoup

html = "<p> <img src='any url'/> </p>   <p><h4>Heading</h4></p>  <p> hello world </p>"

soup = BeautifulSoup(html)

for element in soup.findAll('p'):
    print("".join(element.findAll(text=True, recursive=False)))

```
```
from bs4 import BeautifulSoup

txt = """
<p> <img src="any url"/> </p>     <p> hello world </p>
"""

soup = BeautifulSoup(txt)

for node in soup.findAll('p'):
    print(' '.join(node.findAll(text=True, recursive = False)))

```

OUTPUT:

> 
> hello world
> 
> 
>