I'm trying to populate a lot of templated html documents with html strings contained in a json. For example, my html might look like:
<div class="replace_this_div">
<div>
<p>this text</p>
<p>should be replaced</p>
</div>
</div>
The replacement is in string form and would look something like:
"<p>My replacement code might have standard paragraphs, <a href="fake_link">links</a>, or other html elements such as lists.</p>"
Afterwards, it should simply look like this:
<div class="replace_this_div">
"<p>My replacement code might have standard paragraphs, <a href="fake_link">links</a>, or other html elements such as lists.</p>"
</div>
I've messed around a bit in BeautifulSoup trying to accomplish this. The problem I'm having is that even though I simply want to replace everything inside the designated div, I can't figure out how to do so using my string which is already formatted as html (especially with how beautifulsoup uses tags).
Does anybody have any insight on how to do this? Thanks!