add tag
Given `<p>Bananas <em>in</em> pyjamas are <em>going</em> down the <em>stairs</em>.</p>`

How can I get the HTML string inside the `<p>` tag?

That is, `Bananas <em>in</em> pyjamas are <em>going</em> down the <em>stairs</em>.`

paragraph = '<p>Bananas <em>in</em> pyjamas are <em>going</em> down the <em>stairs</em>.</p>'
paragraphTag = BeautifulSoup(paragraph, "html.parser")
# paragraphTag.???
Top Answer
It seems like there is no direct way to retrieve the string inside a tag.

`.text` and `.strings` will strip the tags.

`.contents` is our best bet but you have to cast to a string first.

return "".join(map(str, paragraphTag.contents))

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.